共计 1211 个字符,预计需要花费 4 分钟才能阅读完成。
博客搭起来了,但使用wordpress的固定链接时,老是报404的错误,google了一下原因,发现lnmp安装后的nginx不支持wordpress的固定链接,需要自己进行设置。
由于是使用lnmp一键安装包,所以要让nginx支持wordpress固定链接非常简单,因为安装后/usr/local/nginx/conf/目录下有一个wordpress.conf文件,将其包含进nginx.conf即可。
具体的操作步骤如下:
[php]
cd /usr/local/nginx/conf/
cp nginx.conf nginx.conf.bak // 将原配置文件备份一下
vi nginx.conf
[/php]
将nginx.conf中的代码
[php]
server
        {
                listen       80;
                server_name gevin.me;
                index index.html index.htm index.php;
                root  /home/wwwroot;
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }
                location /status {
                        stub_status on;
                        access_log   off;
                }
[/php]
替换成(增加了include wordpress.conf;)
[php]
server
        {
                listen       80;
                server_name gevin.me;
                index index.html index.htm index.php;
                root  /home/wwwroot;
                        include wordpress.conf;
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }
                location /status {
                        stub_status on;
                        access_log   off;
                }
[/php]
然后,重启lnmp即可,命令如下:
[php]
/root/lnmp restart
[/php]
最后附上lnmp一键安装包中自带的wordpress.conf的内容,假如你不想包含wordpress.conf,你也可以将wordpress.conf里面的内容拷到nginx.conf里面。
wordpress.conf内容如下:
[php]
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;
        }
}
[/php]
 
                        













 
            