Nginx does not collect the site in the allowed sites?

After more than 10 hours of research, I did not understand why this does not work! I am trying to move my localhost to the folder with enabled sites, which is located in / etc / nginx / sites -enabled / default.

This is a symbolic link from a folder available for sites. When using the following configuration, I get "unable to connect" using localhost: 8080 as my address

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/*; } 

available sites (/ 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; } } 

I can make it work if I put the relevant information from sites on nginx.conf, I just canโ€™t understand why it doesnโ€™t work this way?

Thank!

+72
nginx
Oct 03
source share
3 answers

I had the same problem. This happened because I accidentally used a relative path with a symbolic link.

Are you sure you are using full paths, for example:

 ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf 
+143
Jan 01 '13 at 4:22
source share

Include sites-available/default in sites-enabled/default . This requires only one line.

In sites-enabled/default (new version of the configuration?):

The include path seems to refer to the file that included it

 include sites-available/default; 

See the include documentation.




I believe that some versions of nginx allow you to include / link to other files, just having one line with the relative path to the included file. (At least it looked like some โ€œinheritedโ€ configuration files that I used until the new version of nginx broke them.)

In sites-enabled/default (old version of configuration?):

The include path seems to be relative to the current file

 ../sites-available/default 
+14
Jan 03 '13 at 22:00
source share

Change:

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

to

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

fixed problem

+5
Jan 03 '17 at 21:11
source share



All Articles