5.如何新建站点:
和一般的lnmp一键包不同,采用这个方法所安装的 LNMP 需要手动添加站点配置文件。
进入配置文件目录,新建一个站点配置文件,比如 vi abcd.com.conf。
cd /etc/nginx/conf.d
按照下面添加配置文件:
server {listen 80;
#ipv6#listen [::]:80 default_server;
root /usr/share/nginx/html/abcd.com;
#默认首页文件名index index.php index.html index.htm;
#绑定域名server_name abcd.com;
#伪静态规则include wordpress.conf;
location \ {try_files $uri $uri/ /index.html;}#定义错误页面#error_page 404 /404.html;
location ~ \.php$ {fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;}#PHP}
保存之后重启Nginx,添加及绑定网站即完成。
最后,附上WordPress的Nginx伪静态规则:
location / {if (-f $request_filename/index.html){rewrite (.*) $1/index.html break;}if (-f $request_filename/index.php){rewrite (.*) $1/index.php;}if (!-f $request_filename){rewrite (.*) /index.php;}}