15053971836 注册 / 登录

lnmp的伪静态

时间: 阅读:321
lnmp的伪静态

最佳回答

夜半丶唱情歌

夜半丶唱情歌

2023-01-17 00:46:31

第一步、准备伪静态脚本。
server {
listen 80;
server_name laozuo.org;
server_name_in_redirect off;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
root PATH_ON_SERVER;
index index.php index.html index.htm default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php$args;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
}
# caching of files
location ~* .(ico|pdf|flv)$ {
expires 1y;
}
location ~* .(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
}
第二步,修改文件。
/usr/local/nginx/conf/vhost/www.laozuo.org.conf
这个文件是在添加域名站点时候自动生成的,然后修改这个脚本为第一步的伪静态文件,全部替换就OK。
这样把所有的伪静态都写入的,而没有像wordpress采用调用的方式。效果是一样的。
第三步、重启LNMP。
/root/lnmp restart

最新回答共有2条回答

  • 专业建网站
    回复
    2023-01-17 02:02:34

    在lnmp添加虚拟主机的时候有一个伪静态选项,选择你要使用的php程序对应的伪静态规则。教程看这里http://jingyan.baidu.com/article/db55b609ee255a4ba30a2fe5.html