将域添加到Nginx配置
这是我的问题 我有一个域“example.com”,我希望该域与文件夹/var/www/html/example.com相关联 我已经在/etc/nginx/sites中创建了名为“example.com”的文件将域添加到Nginx配置,nginx,Nginx,这是我的问题 我有一个域“example.com”,我希望该域与文件夹/var/www/html/example.com相关联 我已经在/etc/nginx/sites中创建了名为“example.com”的文件 server { server_name http://example.com; root /var/www/html/example.com; index index.html index.php; # set expiration of asse
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/sites上启用的默认文件
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;
}
我知道问题出在root/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"
希望这是足够的信息,以便有人能提供帮助。
谢谢。我这么做了。问题是我没有将root指定给默认位置,当我这样做时,它就像一个符咒:)
服务器名称
语法错误(请参阅)。另外,您是否已将新站点可用文件符号链接到站点启用目录?是的,其已在站点中启用链接我已修复服务器名称,现在出现新错误2016/02/28 14:07:32[error]11045#0:*317 connect()在连接到上游时失败(111:连接被拒绝),客户端:93.123.47.139,服务器:example.com,$request:“GET/HTTP/1.1”,上游:fastcgi://127.0.0.1:9000,主机:“example.com”
新错误表示端口9000上的服务未运行。