我正在尝试使用基于 nginx 的 wordpress 安装来解决一些问题。该架构在亚马逊中,如下所示:
EC2 Nginx 1.2.4 + php-fpm 服务器 EC2 NFS 服务器 RDS mysql
nginx 从 /mnt/sharedpool/blog 的 nfs 分区读取站点文件
fstab 配置是:
compute-1.amazonaws.com:/mnt/sharedpool /mnt/sharedpool nfs rw,relatime 0 0
nfs 服务器 /etc/exports 配置:
/mnt/sharedpool ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com(rw,同步)
nginx 用户和组设置为 www-data:www-data,站点的根指令设置为 /mnt/sharedpool/blog
我下载了最新版本的 wordpress 并成功安装。问题是登录后,我收到 403 Forbidden。我认为这应该是 wordpress 设置,因为我可以在同一目录中创建并调用 phpinfo()。
更新:
Nginx 服务器配置:
用户www-data www-data; worker_processes 1; pid /var/run/nginx.pid;
事件 { worker_connections 768; # multi_accept on; }
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
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;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Nginx 站点配置:
服务器 { 监听 80; #监听 [::]:80 default_server ipv6only=on; ## 监听 ipv6
root /mnt/sharedpool/blog;
index index.html index.htm;
# 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/ /index.php;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
#autoindex on;
# allow 127.0.0.1;
# allow ::1;
# deny all;
}
#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 /usr/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
提前致谢!
答案1
看起来 nginx 不太确定要为您的网站加载什么索引文件。由于这是一个基于 PHP 的网站 (WordPress),因此应该是index.php
。但是您的index
指令内容如下:
index index.html index.htm;
我会将其改为:
index index.php;