我的机器设置为Ubuntu 16.04,nginx 1.10.2。这是我为我的开发站点设置的配置:
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name commandcenter.dev;
root /var/www/commandcenter;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
一切都没有错误地启动。 Nginx正在运行:
● nginx.service - LSB: Stop/start nginx
Loaded: loaded (/etc/init.d/nginx; bad; vendor preset: enabled)
Active: active (running) since Tue 2016-10-25 04:53:51 UTC; 8min ago
Docs: man:systemd-sysv-generator(8)
Process: 11195 ExecStop=/etc/init.d/nginx stop (code=exited, status=0/SUCCESS)
Process: 11205 ExecStart=/etc/init.d/nginx start (code=exited, status=0/SUCCESS)
Tasks: 2
Memory: 1.3M
CPU: 10ms
CGroup: /system.slice/nginx.service
├─11216 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
└─11218 nginx: worker process
Oct 25 04:53:51 commandcenter systemd[1]: Stopped LSB: Stop/start nginx.
Oct 25 04:53:51 commandcenter systemd[1]: Starting LSB: Stop/start nginx...
Oct 25 04:53:51 commandcenter systemd[1]: Started LSB: Stop/start nginx.
我认为它在80端口上市:
$ sudo netstat -nlp | grep nginx
6:tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11216/nginx.conf
8:tcp6 0 0 :::80 :::* LISTEN 11216/nginx.conf
我可以ping服务器并且可以正常运行。当我尝试用curl或通过浏览器点击它时,我得到:
$ curl -I commandcenter.dev
curl: (7) Failed to connect to commandcenter.dev port 80: Connection refused
我不确定我需要进一步检查或更改以通过nginx。我检查了错误和访问日志,但没有任何内容。
答案 0 :(得分:0)
将server_name
设为
server {
server_name .commandcenter.dev;
}
如果您想捕获域,任何子域和完全限定的域名。
如果您只有一个server
阻止,则server_name是可选的。