Reputation: 13
I'm trying to setup several Websites on an NGINX server running under Debian Linux locally inside Oracle VM VirtualBox.
Versions: Oracle VM VirtualBox: 4.3.10, Debian: Wheezy, NGINX: 1.2.1
The /etc/nginx/nginx.conf file:
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
autoindex on;
index index.html index.htm index.php;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
error_page 404 = /usr/share/nginx/www/404.html;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
The /etc/nginx/sites-available/default file:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/www;
server_name vmhost;
location / {
try_files $uri $uri/ /index.htm /index.html =404;
}
error_page 404 /404.html;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
location ~ /\.ht {
deny all;
}
}
The /etc/nginx/sites-available/testsitea file:
server {
listen 80;
listen [::]:80;
server_name mytest;
root /usr/share/nginx/www/testfolder/public;
location / {
try_files $uri $uri/ /index.html;
}
}
The symbolic links:
root@debian-nginx:/etc# ls -l /etc/nginx/sites-enabled
total 0
lrwxrwxrwx 1 root root 34 Mar 17 13:47 default -> /etc/nginx/sites-available/default
lrwxrwxrwx 1 root root 36 Mar 25 14:30 testsitea -> /etc/nginx/sites-available/testsitea
When I send my browser to http://192.168.1.45/
, I see the expected "Welcome to nginx!"
If I set the browser address to http://192.168.1.45/vmhost
, I also see "Welcome to nginx!"
When I direct my browser to http://192.168.1.45/mytest
what I expect to see is the static index.html file of my test site. What I actually see is the "Welcome to nginx!" file.
The error.log file shows only "signal process started." I have verified that the folder permissions are set to 755 and the file permissions are 644.
Can you see where my errors are?
Upvotes: 1
Views: 3922
Reputation: 4526
Since both your configuration files are configured to listen on the same port (80), the requests are sent to the server configuration which has default_server
marked in it, which is the /etc/nginx/sites-available/default
configuration whose root directory is at /usr/share/nginx/www
.
To get the expected behavior, you can follow one of these options:
default_server
and remove the same from the default configuration file.192.168.1.45 mytest
192.168.1.45 vmhost
and connect to the websites as http://mytest
or http://vmhost
as suggested previously by @alexeyten
Upvotes: 1
Reputation: 14374
You defined server mytest
, but request page /mytest
from default server.
You have to add string
192.168.1.45 mytest
to yours /etc/hosts
file and point your browser to http://mytest/
.
Upvotes: 0