【发布时间】:2014-03-26 17:20:25
【问题描述】:
我正在尝试在 Oracle VM VirtualBox 内本地运行在 Debian Linux 下的 NGINX 服务器上设置几个网站。
版本: Oracle VM VirtualBox:4.3.10,Debian:Wheezy,NGINX:1.2.1
/etc/nginx/nginx.conf文件:
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/*;
}
/etc/nginx/sites-available/default 文件:
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;
}
}
/etc/nginx/sites-available/testsitea 文件:
server {
listen 80;
listen [::]:80;
server_name mytest;
root /usr/share/nginx/www/testfolder/public;
location / {
try_files $uri $uri/ /index.html;
}
}
符号链接:
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
当我将浏览器发送到http://192.168.1.45/ 时,我看到了预期的“欢迎使用 nginx!”
如果我将浏览器地址设置为http://192.168.1.45/vmhost,我还会看到“Welcome to nginx!”
当我将浏览器指向http://192.168.1.45/mytest 时,我希望看到的是我的测试站点的静态 index.html 文件。我实际看到的是“欢迎使用 nginx!”文件。
error.log 文件仅显示“signal process started”。我已经验证文件夹权限设置为755,文件权限设置为644。
你能看到我的错误在哪里吗?
【问题讨论】:
标签: nginx virtualbox