gpt4 book ai didi

Nginx 未在已启用站点中拾取站点?

转载 作者:行者123 更新时间:2023-12-03 04:54:08 25 4
gpt4 key购买 nike

经过 10 多个小时的研究,我还没弄清楚为什么这不起作用!我正在尝试将本地主机移动到/etc/nginx/sites-enabled/default 中的启用站点的文件夹。

它是来自站点可用文件夹的符号链接(symbolic link)。使用以下配置时,使用 localhost:8080 作为我的地址,出现“无法连接”

nginx.conf(/usr/local/nginx/conf/nginx.conf):

user  www-data;
worker_processes 2;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

include /etc/nginx/sites-enabled/*;
}

可用站点(/etc/nginx/sites-available/default):

server {
listen 8080;
root /home/myusername/myown/customdirectory;
index index.php index.html index.htm;
server_name localhost;

location / {
try_files $uri $uri/ /index.html;
}

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}


error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}

如果我将可用站点的相关信息放入 nginx.conf,我就可以使其工作,我只是不明白为什么它不能以这种方式工作?

谢谢!

最佳答案

我也遇到了同样的问题。这是因为我不小心使用了带有符号链接(symbolic link)的相对路径。

您确定使用了完整路径吗,例如:

ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf

关于Nginx 未在已启用站点中拾取站点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12715871/

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