我昨天启动了VPS,并安装了WordPress,并已完成基本设置。但是永久链接怎么办?没有人希望使用默认的丑陋URL结构。我试图了解http://wiki.nginx.org/WordPress,但有趣的是“我不知道在哪里插入这些代码”。他们可能认为所有读者都对Nginx十分了解,这并不好笑。
因此,我很确定.htaccess在nginx中不起作用。怎么办?在哪里放置使自定义永久链接起作用的代码?PS:您知道,如果我设置了一个自定义的永久链接,则输出为404页面,例如:
因此,请我提供一个简单的指南,告诉您“编辑demo.php文件并将其放在X后面的代码下面”。
其他信息:我的webroot是/ usr / share / nginx / html,那里有两个WordPress。第一个:/ usr / share / nginx / html目录,第二个:/ usr / share / nginx / html / video目录。我要为他们两个都提供漂亮的网址。我将chmod wp-content都设置为775。
Nginx根本不支持.htaccess。
您的nginx安装是否正确,以便php-fpm处理php文件?您的错误屏幕截图尚不清楚。
您必须编辑您的nginx配置文件,并告诉它使用wordpress控制器来引导请求通过。
您的nginx.conf应该有一个http块,在该服务器块内,并且在某些位置块内。您需要找到正确的服务器块并插入以下位置块
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php?$args;
}
这是我运行的完全正常工作的wordpress nginx.conf的完整示例:
user www-data;
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
client_max_body_size 20M;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
sendfile on;
keepalive_timeout 30;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 80 default_server;
server_name www.site.com;
root /var/www;
index index.php;
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php?$args;
}
# pass the PHP scripts to FastCGI server
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句