0%

nginx 配置文件更新3

2017年7月17日 下午4:05

来源:https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/
目的:解决wordpress修改固定连接后不能正常访问(404 or 有点尴尬诶!该页无法显示。),其实我的没改的时候也是(有点尴尬诶!该页无法显示)、

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
30
31
32
33
34
35
36
37
38
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /var/www;
index index.html index.htm index.php;

# Make site accessible from http://localhost/
server_name localhost;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_NAME $1;
fastcgi_param PATH_INFO $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location /wordpress {
try_files $uri $uri/ /wordpress/index.php?$args;
}

}