typecho在nginx开启永久链接

最近把家里的NAS平台从群晖迁移到了Openmediavault,简称OMV。就是因为群晖管理硬盘实在太傻了,动不动就把硬盘全部叫起来跑步,新NAS机箱是六盘位的,不希望硬盘没事就转啊转,一来费电二来吵闹兼吸尘。

选来选去用上了OMV系统,这个比较合胃口,简单清爽,关键是硬盘管理比较友善而且适合家用,希望24小时待机候命又不希望它没事瞎跑。

刚开始想用docker搞定所有的LNMP,但是试了几个都不太好玩而且docker的mariadb实在太难练上去了,搞了半天干脆用OMV自带的PHP-FPM和NGinx服务器算了,点几下鼠标搞定了。然后把群晖的blog迁移过来,因为换了平台,之前的静态链接.htaccess没法用了,只能又重新琢磨怎么在nginx下面搞掂永久链接,看了很多资料都是很老的了,好不容易找到一篇新点的平台文章借鉴了一下。

链接这里

但是里面内容还是跟自己的实际情况有些出入,根据实际修改了一下,跑了一下没问题了就记录下俩方便自己下一次折腾。
作者的配置文件:

location / {
# one line for typecho staticize and with cgi.fix_pathinfo=0 in php.ini more secure
try_files $uri $uri/ @typecho;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#try_files $uri @typecho;
fastcgi_pass 127.0.0.1:9000;
#include from snippets/fastcgi-php.conf:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
}
location @typecho {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include fastcgi_params;
}

 

但是自己用的是FPM的socket,所以要最后修改如下:

server {
listen 81;
listen [::]:81;
listen 444 ssl http2;
listen [::]:444 ssl http2;
ssl_certificate /etc/ssl/certs/openmediavault-42052d8e-d4b9-4fda-985b-12345678901.crt;
ssl_certificate_key /etc/ssl/private/openmediavault-42052d8e-d4b9-4fda-985b-12345678901.key;
set $root_path "/srv/SSD/web";
root $root_path;
index index.html index.php;
set $socket "unix:/var/run/fpm-f1465962-94b9-4530-9a84-12345678901.sock";
location / {
try_files $uri $uri/ @typecho;
}
location ~ \.php$ {
fastcgi_pass $socket;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
}
location @typecho {
fastcgi_pass $socket;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include fastcgi_params;
}
access_log /var/log/nginx/b5a4341d-4b02-484d-9403-12345678901-access.log;
error_log /var/log/nginx/b5a4341d-4b02-484d-9403-12345678901-error.log;
autoindex on;
large_client_header_buffers 4 8k;
}
Leave a Reply

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注