我已经在一台安装了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。我已经检查了错误日志和访问日志,但没有发现问题。
/etc/hosts/
并添加commandcenter.dev 127.0.0.1
到其中,以便它知道必须通过环回接口进行访问。 - Keenan Lawrence