Linux

Nginx目錄(21:是一個目錄)

  • October 16, 2016

我正在嘗試nginx在 AWS Linux 上進行配置。我可以讓它在一個站點上工作,但是當我嘗試添加另一個站點時,我不斷收到以下錯誤:

nginx: [crit] pread() "/home/ec2-user/public/sites/example.com" failed (21: Is a directory)

這是我的nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
   worker_connections 1024;
}

http {
   log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';

   access_log  /var/log/nginx/access.log  main;

   sendfile            on;
   tcp_nopush          on;
   tcp_nodelay         on;
   keepalive_timeout   65;
   types_hash_max_size 2048;

   include             /etc/nginx/mime.types;
   include             /home/ec2-user/public/sites/*;
   default_type        application/octet-stream;

   include /etc/nginx/conf.d/*.conf;

   index   index.html index.htm;

   server {
       listen       80 default_server;
       listen       [::]:80 default_server;
       server_name  localhost example.es www.example.es;
       root         /home/ec2-user/public/sites/es-example;

       location / {
       }

       error_page 404 /404.html;
           location = /40x.html {
       }

       error_page 500 502 503 504 /50x.html;
           location = /50x.html {
       }
   }

   server {
       listen       80;
       listen       [::]:80;        
       server_name  example.com www.example.com;
       root         /home/ec2-user/public/sites/en-example;

       location / {
       }

       error_page 404 /404.html;
           location = /40x.html {
       }

       error_page 500 502 503 504 /50x.html;
           location = /50x.html {
       }
   }
}

兩個目錄example.com都有example.es一個index.html. 兩個目錄的權限如下。

-rwxr-xr-x 1 ec2-user ec2-user

有任何想法嗎?謝謝!

問題在於這一行:

include             /home/ec2-user/public/sites/*;

nginx 使用上面的指令來載入/包含其他配置選項。只有正確的 nginx 配置文件應該放在

/home/ec2-user/public/sites/

如果您還在那裡放置目錄或站點(內容)文件,nginx 將無法包含它們。請查看 nginx 文件

http://nginx.org/en/docs/ngx_core_module.html#include

引用自:https://serverfault.com/questions/771878