wordpress 后台固定链接自定义为 /%post_id%.html,然后发布文章都是 404···有点崩溃。服务器是 centos 系统,用的宝塔面板,搜索了好多解决方法没找到合适的,毕竟是菜鸟~ nginx 配置文档贴出来大神们来看看··· #user nobody; worker_processes 1;
#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;
#pid logs/nginx.pid;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
1
justinwu 2018-03-15 03:37:16 +08:00 via iPhone
睡不着,瞎答题。
你这配置不对吧,怎么处理 php 脚本都注掉了。当然打开也是不行的,君不见只有.php 扩展名 pass 给 fast cgi 或是 apache ?文章网址搞成.html,被 nginx 默认规则匹配了,找不到就 404 了。 需要配置 url rewrite 吧,看看 wordpress 说明文档。 |
2
caoguo 2018-03-15 05:16:00 +08:00 via Android
第一行 #user nobody 要改成 root 或有权限的用户
|
3
taifus 2018-03-15 07:51:46 +08:00 via Android
简单点说,宝塔后来有个设置伪静态的可以选择,改成 wp 的,然后进 wp 后台把固定链接再保存一下,然后就行了。
|
4
zyxbcde 2018-03-15 07:55:40 +08:00 via Android
改成数字链接,就是 id=xxx 那种,在 wordpress 设置里面,应该有更好的办法,不过这个最简单。。
|
6
DT27 2018-03-15 07:57:07 +08:00
还是喜欢 apache 跟.htaccess 文件~
nginx 那动不动 502 的错误还没有具体信息你们是怎么忍受的。。。 v2ex 都动不动就 502··· |
7
DT27 2018-03-15 08:04:29 +08:00
location / {
# This is cool because no php is touched for static content. # include the "?$args" part so non-default permalinks doesn't break when using query string try_files $uri $uri/ /index.php?$args; } 上面是伪静态的规则。 下面是 php 解析的,具体配置你自己试试。 location ~ \.php$ { #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi.conf; fastcgi_intercept_errors on; fastcgi_pass php; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; } |
8
sjwuny 2018-03-15 08:53:38 +08:00
伪静态规则没设置对
|
9
moxian2014 OP @taifus 哈哈 感谢老哥 可以了 看来还是对宝塔不太熟啊
|
10
moxian2014 OP @taifus 感谢
|
11
taifus 2018-03-15 13:13:58 +08:00 via Android
@moxian2014 不客气,原来也遇到过一样的问题。
|