Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx fails successfully start with error pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)

I have a simple django website im trying to load with nginx and uwsgi .

When i try to test my nginx configuration i get the following:

$ sudo nginx -t
nginx: [crit] pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

my sites-available/default config looks like:

# the upstream component nginx needs to connect to
upstream django {
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    server_name website.com xx.xx.x.x; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 2M;   # adjust to taste

    # Django media
    #location /media  {
    #    alias ;  # your Django project's media files - amend as required
    #}

    location /static {
        alias /static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  127.0.0.1:8001;
        include     uwsgi_params; # the uwsgi_params file you installed
    }
}

I viewed nginx error logs in /var/log/nginx/error.log and found:

2019/11/26 14:29:53 [crit] 7702#7702: pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)
2019/11/26 15:05:25 [crit] 7736#7736: pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory)

I also verified a symlink has been made between nginx's sites-available/ and sites-enabled:

$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
ln: failed to create symbolic link '/etc/nginx/sites-enabled/sites-available': File exists

what could be going wrong here?

Thanks

like image 895
Jshee Avatar asked Nov 26 '19 15:11

Jshee


1 Answers

You have symlinked the directory and not the file called default.

There should be a file in sites-enabled called default which is a symlink to the file called default in the sites-available directory.

Try this:

cd /etc/nginx/sites-enabled/
rm sites-available;

The above should remove the symlink that is causing the error.

cd /etc/nginx/sites-enabled/
ln -s ../sites-available/default;

The above should create a symlink called default.

like image 167
Richard Smith Avatar answered Nov 19 '22 13:11

Richard Smith