2
我正試着用nginx開始。但我真的不明白這個代碼出了什麼問題。Nginx和子域名
正如你可以看到有兩個域名:
- mauromarano.it
- dev.mauromarano.it
第一個域承載一個WordPress博客。
#####################
# mauromarano.it/ #
####################
server {
listen 80;
# listen [::]:80 default_server;
root /usr/share/nginx/mauromarano.it/public_html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name mauromarano.it www.mauromarano.it;
access_log /usr/share/nginx/mauromarano.it/logs/access.log;
error_log /usr/share/nginx/mauromarano.it/logs/error.log;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /blog {
try_files $uri $uri/ /blog/index.php?$args;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(/blog)(/.*)$;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/mauromarano.it/public_html$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
#####################
# mauromarano.com #
####################
server {
listen 80;
# listen [::]:80 default_server;
root /usr/share/nginx/mauromarano.com/public_html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name mauromarano.com www.mauromarano.com;
access_log /usr/share/nginx/mauromarano.com/logs/access.log;
error_log /usr/share/nginx/mauromarano.com/logs/error.log;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/mauromarano.com/public_html$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
#####################
# dev.mauromarano.it/ #
####################
server {
listen 80;
# listen [::]:80 default_server;
root /usr/share/nginx/dev.mauromarano.it/public_html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name dev.mauromarano.it www.dev.mauromarano.it;
access_log /usr/share/nginx/dev.mauromarano.it/logs/access.log;
error_log /usr/share/nginx/dev.mauromarano.it/logs/error.log;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(/blog)(/.*)$;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/dev.mauromarano.it/public_html$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
我在哪裏錯了?
我的目標是讓這兩個域名工作。但通過這種方式,子域(dev.mauromarano.it)不起作用。
你有什麼問題?什麼不工作?你的目標是什麼? – kevingessner 2013-05-06 19:11:03
我的目標是讓這兩個域名工作。但通過這種方式,子域(dev.mauromarano.it)不起作用。 – gaggina 2013-05-06 19:19:56