[英]Vhost on nginx does not function as expected
我的域名注冊商的DNS到達了我的服務器,並獲得了Nginx默認頁面,因此已正確配置
我復制了當前正在運行的Nginx虛擬主機,更改了server_name
和conf文件的名稱,僅此而已。
差異:
diff 701sm.club.conf drz400.info.conf
3c3
< server_name www.701sm.club 701sm.club;
---
> server_name www.drz400.info drz400.info;
然后我重新啟動了nginx。
這是整個無法運行的虛擬主機:
server {
listen 80;
server_name www.701sm.club 701sm.club;
index index.php index.html index.htm;
access_log /var/www/drz400.info/logs/access.log;
error_log /var/www/drz400.info/logs/error.log;
location / {
root /var/www/drz400.info/production;
}
location ~ \.php$ {
root /var/www/drz400.info/production;
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
這兩個站點都應該訪問我的.../production/index.html
,但是只有一個可以。 這有什么問題嗎?
請嘗試以下代碼,
server {
listen 80;
server_name www.701sm.club 701sm.club;
index index.php index.html index.htm;
access_log /var/www/drz400.info/logs/access.log;
error_log /var/www/drz400.info/logs/error.log;
root /var/www/drz400.info/production;
location / {
try_files $uri /index.html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
只是對您的log指令感到好奇,當您的域為www.701sm.club時,您將日志指向/var/www/drz400.info/logs/error.log。 如果您訪問www.701sm.club,您的error.log上是否有任何錯誤?
發生了什么類型的錯誤?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.