在其他 StackExchange 论坛上尝试三次后,我希望在这里得到答案。
我将 wordpress 网络服务器从 apache2 切换到 nginx(请注意,我想使用现有的 wordpress 实例),但现在我无法连接到它。有时我会得到connection refused
,如果不是这种情况,我会得到403: Forbidden
。
解决该问题的最佳解决方案是什么?我的 nginx.conf:
user www-data;
worker_processes auto;
pid /run/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"';
error_log /var/log/nginx_error.log error;
access_log /var/log/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # no sslv3 (poodle etc.)
ssl_prefer_server_ciphers on;
# Gzip Settings
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_min_length 512;
gzip_types text/plain application/x-javascript text/javascript application/$
fastcgi_cache_path /usr/share/nginx/cache/fcgi levels=1:2 keys_zone=microca$
include /etc/nginx/sites-enabled/*.conf;
}
我的wordpress.conf:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name snapecraft.ddns.net;
access_log /var/log/nginx/vhost1.access.log;
error_log /var/log/nginx/vhost1.error.log;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
感谢您的帮助!
答案1
如果您只是想列出目录内容,请使用autoindex
;例如:
location /somedir {
autoindex on;
}
sudo nginx -s 重新加载