0
这里是我的问题加入域的Nginx配置
我有域“example.com”和我想的是域名与文件夹/var/www/html/example.com相关
我已经创建一个名为 “example.com” 文件/ etc/nginx的/网站可用
server {
server_name http://example.com;
root /var/www/html/example.com;
index index.html index.php;
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
location/{
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
这里是我的默认放在/ etc/nginx的/启用的站点 -
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 188.226.145.195;
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /example.com/ {
try_files $uri $uri/ /example.com/index.php;
}
文件
我知道问题出在根的/ var/www/html等,但不能化解它
错误日志:
2016/02/27 13:53:53 [error] 10139#0: *11 directory index of "/var/www/html/" is forbidden, client: xxx.xx.xx.xx, server: 188.226.145.195, request: "GET/HTTP/1.1", host: "www.example.com"
希望这是足够的信息,以便some1可以提供帮助。 谢谢。
'server_name'语法错误(见[这里](HTTP:// nginx.org/en/docs/http/server_names.html))。另外,您是否已将新网站可用文件链接到启用网站的目录? –
是的,它连接在sitest-enabled我修复了server_name,现在得到了新错误'2016/02/28 14:07:32 [error] 11045#0:* 317连接()失败(111:连接被拒绝)到上游,客户端:93.123.47.139,服务器:example.com,$ request:“GET/HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“example.com” ' – IdlleF
新的错误意味着端口9000上的服务未运行。 –