大网数据广告活动
服务器运维问答

Nginx directory (21: Is a directory)

· 52CE 我爱测

I'm trying to configure nginx on AWS Linux. I can get it working for one site, but when I try to add another I continually receive the following error: nginx: [crit] pread() "/home/ec2-user/public/sites/example.com" failed (21: I…

问题原文

原帖链接 · David · CC BY-SA 3.0

I'm trying to configure nginx on AWS Linux. I can get it working for one site, but when I try to add another I continually receive the following error:

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

This is my 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 {
        }
    }
}

Both directories example.com and example.es have an index.html. The permissions for both directories are as follows.

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

Any ideas? Thanks!

已采纳解答

原帖链接 · M.B. · CC BY-SA 3.0

The problem is with this line:

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

The directive above is used by nginx to load/include additional configuration options. Only proper nginx configuration files should be placed under

/home/ec2-user/public/sites/

If you place there also directories or site (content) files nginx won't be able to include them. Please check the nginx documentation

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。