我刚开始与Nginx的尝试使用虚拟主机,但不能包裹我的头周围有什么错我的configuration…
以下是启用网站的文件夹的声音:
root@cavalier:/etc/nginx/sites-enabled# ls -hal total 12K drwxrwxr-x 2 root vnc 4.0K Jul 28 18:06 . drwxr-xr-x 5 root root 4.0K Jul 1 16:58 .. -rw-r--r-- 1 root root 360 Jul 28 18:07 default lrwxrwxrwx 1 root root 31 Jul 28 18:01 example1.com -> ../sites-available/example1.com lrwxrwxrwx 1 root root 33 Jul 28 17:57 example2.com -> ../sites-available/example2.com
默认服务器块的内容:
root@cavalier:/etc/nginx/sites-enabled# cat default server { listen 80 default_server; root /www/example.com; index index.html index.php; location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
示例1服务器块:
root@cavalier:/etc/nginx/sites-enabled# cat example1.com server { listen example1.com:80; server_name www.example1.com example1.com; root /www/example1.com; index index.html index.php; location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
example2服务器块:
root@cavalier:/etc/nginx/sites-enabled# cat example2.com server { server_name example2.com; root /www/example2.com; index index.php; location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
出于某种原因,nginx只能为example1.com提供所有域的文件。 它甚至不理会默认的服务器configuration,直接进入example1。
对不起,我是nginx新手,主要使用Apache。 我猜这应该是相对简单的,我只是失去了一些东西…我花了几个小时试图弄清楚,但任何帮助,将不胜感激。
Server1与请求最具体的匹配:IP:端口,而另外两个匹配端口。 所以nginxselect服务器1来处理所有到这个IP:端口对的请求