阳光越强烈
阴影就越是深邃

LNMP下给已存在的虚拟机追加或修改伪静态规则

使用LNMP一键安装包,在添加虚拟机的时候没有添加伪静态,但是后来真正使用程序的时候需要伪静态,所以想给已经存在的虚拟主机追加伪静态规则,由于Apache开启伪静态支持后可以直接修改.htaccess文件就行,但是nginx需要新建一个例如名字为 www.taiyangta.com.conf文件,编辑该文件,把伪静态规则输入进去(注意htaccess的伪静态规则需转成nginx的conf规则才行)然后,在/usr/local/nginx/conf/vhost下编辑 www.taiyangta.com.conf文件,打开文件如下(假如目前的伪静态为discuzx,注意红色字体):
server
{
listen 80;
server_name www.taiyangta.com www.taiyangta.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/域名;

include discuzx.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log off;
}

文件,修改include discuz.conf 文件名称为你刚刚的include wordpress.conf (修改为wordpress伪静态规则)就可以了,假如需要弄成LNMP没有现成的规则,需要自己上传一个xxx.conf的伪静态规则文件到/usr/local/nginx/conf/目录下。
最后执行 /usr/local/nginx/sbin/nginx -s reload 命令重启 nginx 就OK了

赞(0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址