LNMP nginx配置伪静态规则

LNMP nginx配置伪静态规则,第1张

第一步、准备伪静态脚本。

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

个人建站的办法很简单,首先网站服务器选择1核2G1M,40G高效云盘。要准备以下的资料

选择云服务器,例如阿里或者腾讯等

国内服务器要备案,hk和国外服务器不用。

建立网站环境,这时候用lnmp环境,速度更快,安装 wp程序。

安装wp过程就很简单了,按照页面提示输入数据库名、账号密码,然后输入网站title,后台账号密码,邮箱,安装成功就可以了

解析域名到服务器

WordPress程序选择的主机配置应该支持php。支持伪静态。首选Linux系统主机。

请点击输入图片描述


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11300964.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存