gpt4 book ai didi

nginx - nginx 上的虚拟主机无法按预期运行

转载 作者:行者123 更新时间:2023-12-04 19:44:09 31 4
gpt4 key购买 nike

我的域名注册商的 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;
}
}

关于nginx - nginx 上的虚拟主机无法按预期运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39908908/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com