我在配置wordpress nginx设置时遇到问题。 这是我的nginx配置
server {
listen 80;
server_name wordpress.project;
access_log /var/log/nginx/wordpress.project/access.log;
error_log /var/log/nginx/wordpress.project/error.log;
root /var/www/wordpress.project;
location / {
index app_dev.php;
if (-f $request_filename) {
break;
}
rewrite ^(.*)$ /app_dev.php last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
主机文件设置为127.0.0.1 wordpress.project
设置文件夹权限
sudo chmod -R a+rw /var/www/wordpress.project
sudo chown -R www-data:www-data /var/www/wordpress.project
设置符号链接
sudo ln -s /etc/nginx/sites-available/wordpess.project /etc/nginx/sites-enabled/wordpess.project
当我尝试访问wordpress.project说
时仍然有错误找不到文件
Project具有经典的wordpress文件结构 这是nginx中wordpress的正确配置吗?如果它不是最好的方法吗?
答案 0 :(得分:1)
试试这个
server
{
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/wordpress.project;
index index.php index.html index.htm;
server_name your_domain.com;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
请在更改配置后重新启动Nginx(sudo service nginx restart)