写在前面
博客折腾来折腾去,文章没写几篇,倒是沉浸在更换各种框架中,前面wordpress玩了一阵,功能虽然强大,但是太臃肿了,什么功能都需要自己捣鼓配置,因为加载的资源都是国外的,各种卡慢,实在不能忍受了,找找国内轻量级的cms或者博客框架,有两个选择,emlog和typecho,但是emlog没找到合适的主题,类似joe主题都是半成品,最终选择了typecho,前面各种LNMP安装麻溜的安装下来,启动typecho进入主页都没问题,近后台时悲剧来了,直接404, 折腾了一晚上找到原因,记录一下。
解决方法
网上的说法是typecho需要path_info的支持,
参考:
https://blog.csdn.net/funche/article/details/99294581
https://www.php.cn/topic/bt/473975.html
https://blog.csdn.net/qq_34185638/article/details/124038071
最终采用这个帖子的方法解决问题:
https://boke112.com/post/5112.html
修改/etc/nginx/sites-available/default
,增加内容:
1
2
3
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
完整内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
server {
listen 80 default_server;
listen [::]:80 default_server;
root /home/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
location ~ .*\.php(\/.*)*$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}