日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Ngnix搭建静态网页和安装wordpress

發布時間:2023/12/13 25 生活家
生活随笔 收集整理的這篇文章主要介紹了 Ngnix搭建静态网页和安装wordpress 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用nginx搭建wordpress和靜態網站。以下操作均實在ubuntu1604完成。

安裝nginx

apt install nginx

驗證安裝是否完成。在瀏覽器打開127.0.0.1,能夠看到nginx啟動則代表完成。

新建自己的靜態文件index.html

index.html

<html>
<haed>
</head>
  <body>
    <p>my first page</p>
  </body>
</html>

創建index.html的配置文件demo.conf

demo.conf

server {

   listen 80;                 #監聽端口
   server_name localhost;     #域名解析
   root /home/demo;   #html所在目錄

   location / {
      index index.html;       #html的名字
   }
}

移動配置文件到/etc/nginx/conf.d目錄下

能夠配置nginx的文件有三個地方,分別是:

/etc/nginx/nginx.conf
/etc/nginx/conf.d
/etc/nginx/sites-enabled

其中/etc/nginx/nginx.conf 為主配置文件,在nginx讀取配置文件時,首先讀取nginx.conf,然后再讀取/etc/nginx/conf.d中以conf結尾的文件,最后讀取/etc/nginx/sites-enabled 鏈接的文件。所以這里選擇第二種方式,新建demo.conf文件放在/etc/nginx/conf.d目錄下。

重新加載nginx配置文件

nginx -s reload

安裝wordperss


WordPress是使用PHP語言開發的博客平臺,用戶可以在支持PHP和MySQL數據庫的服務器上架設屬于自己的網站

安裝mysql數據

apt install mysql-server

安裝php

apt install php7.0 
apt install libapache2-mod-php7.0 
apt install php7.0-mysql

下載wordpress

wget  https://cn.wordpress.org/latest-zh_CN.tar.gz

解壓wordpress

tar zvxf latest-zh-CN.tar.gz

創建數據庫wordpress

create database wordpress

創建wordpress的配置文件

cp wp-config-sample.php wp-config.php

修改wordpress的配置文件

復制wordpress到/var/www文件夾

cp -r wordpress  /var/www/

新增nginx配置

/etc/nginx/conf.d/目錄下新增wordpress.conf配置文件,同時刪除上面的demo.conf配置文件
wordpress.conf

server {

     listen 80;
     listen [::]:80;
     root /var/www/wordpress;
     index index.html index.php index.nginx-debian.html;

     server_name localhost;

     location / {
        try_files $uri $uri/ =404;
     }
     
     location ~ .php$ {

         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/run/php/php7.0-fpm.sock;
     }

}

重新加載配置文件

nginx -s reload

訪問localhost安裝wordpress

總結

以上是生活随笔為你收集整理的Ngnix搭建静态网页和安装wordpress的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。