我转移到一个更便宜的 VPS 主机,其中我之前的配置被设置为显示来自 /home/sam/www/website/index.html 的文件
但我似乎无法在新服务器上实现这一点,默认目录是 /var/www/website/index.html
您对配置有什么想法吗?大多数都是默认的
始终显示默认的欢迎 nginx html 文件
server {
listen 80;
server_name samayres.net www.samayres.net;
index index.html index.php index.htm;
access_log /home/sam/www/samayres.net/logs/access_logs.log;
error_log /home/sam/www/samayres.net/logs/error_logs.log;
root /home/sam/www/samayres.net;
error_page 401 /home/sam/www/samayres.net/error/401.html;
error_page 403 /home/sam/www/samayres.net/error/403.html;
error_page 404 /home/sam/www/samayres.net/error/404.html;
error_page 500 /home/sam/www/samayres.net/error/500.html;
error_page 501 /home/sam/www/samayres.net/error/501.html;
error_page 502 /home/sam/www/samayres.net/error/502.html;
error_page 503 /home/sam/www/samayres.net/error/503.html;
error_page 504 /home/sam/www/samayres.net/error/504.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
# rewrite adminpanel to use https
rewrite ^/adminpanel(.*)$ https://$host$uri permanent;
# Add trailing slash to */wp-admin requests. Needed if wordpress is installed later
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ \.php$ {
try_files index index.php $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}
答案1
在您的server {
部分中,更改:
root /home/sam/www/website;
到:
root /var/www/website;