Nginx没有在启用站点的站点上接站吗? [英] Nginx not picking up site in sites-enabled?

查看:205
本文介绍了Nginx没有在启用站点的站点上接站吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过十多个小时的研究,我仍未弄清楚为什么这行不通!我正在尝试将本地主机移到位于/etc/nginx/sites-enabled/default中的启用了站点的文件夹中.

After over 10 hours of research I have not figured out why this doesn't work! I am trying to move my localhost to my sites-enabled folder which is in /etc/nginx/sites-enabled/default.

它是站点可用文件夹中的符号链接.使用以下配置时,我使用本地主机:8080作为地址获得无法连接"

It IS a symlink from the sites-available folder. When using the following configuration I get an "unable to connect" using localhost:8080 as my address

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

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 (/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的可用站点中获取相关信息,我就能使它正常工作,我只是想不通为什么它不能以这种方式工作?

I can get this working if I put the relevant info from sites available to the nginx.conf, I just can't figure out why it doesn't work this way?

谢谢!

推荐答案

我遇到了同样的问题.这是因为我不小心在符号链接中使用了相对路径.

I had the same problem. It was because I had accidentally used a relative path with the symbolic link.

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

Are you sure you used full paths, e.g.:

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

这篇关于Nginx没有在启用站点的站点上接站吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆