1.获取管理员权限:
sudo su
2. 配置Nginx以使用PHP处理器
sudo vim /etc/nginx/sites-available/default
3.往 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;
}
更改后的nignx.conf如下:
4.检查nginx是否有误:
sudo nginx -t
5.启动与重启nginx
sudo service nginx start
sudo systemctl reload nginx
6.更改固定链接为:
http://ip/post/%postname%.html |
硬件之家,技术向前。