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

2024-01-11

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

它是来自站点可用文件夹的符号链接。使用以下配置时,使用 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,我就可以实现此功能,我只是不明白为什么它不能以这种方式工作?

Thanks!


我有同样的问题。这是因为我不小心使用了带有符号链接的相对路径。

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

ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Nginx 未在已启用站点中拾取站点? 的相关文章

随机推荐