这是我的问题
我有域名“example.com”,我希望该域名与文件夹/var/www/html/example.com相关联
我在/ etc / nginx / sites-available
中创建了名为“example.com”的文件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-enabled上的默认文件
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"
希望这是足够的信息,所以some1可以提供帮助。 感谢。
答案 0 :(得分:0)
我做到了,问题是我没有将root设置为默认位置,当我这样做时就像魅力一样:)