Nginx没有在网站启用中获取网站?

时间:2012-10-03 19:56:57

标签: nginx

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

它是来自sites-available文件夹的符号链接。使用以下配置时,我使用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/*; 
}

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的可用站点中提取出来,我可以解决这个问题,我只是无法弄清楚为什么它不能以这种方式工作?

谢谢!

2 个答案:

答案 0 :(得分:177)

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

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

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

答案 1 :(得分:14)

改变自:

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

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

解决了我的问题

相关问题