This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

1 vote

Please note that I am trying to setup a php laravel website on amazon aws EC2. I have been following this guide:

When I get to the point where I need to execute this command:

$ nginx -t

It gives me these errors.

ubuntu@ip-172-31-1-135:/etc/nginx/sites-available$ nginx -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2023/06/25 01:14:54 [warn] 30686#30686: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2023/06/25 01:14:54 [emerg] 30686#30686: open() "/etc/nginx/sites-enabled/laravelapp.conf" failed (2: No such file or directory) in /etc/nginx/nginx.conf:60
nginx: configuration file /etc/nginx/nginx.conf test failed

Does anyone have any suggestions? TIA.


This is what I am getting now:

ubuntu@ip-172-31-1-135:~$ sudo nginx -t
nginx: [emerg] open() "/etc/nginx/sites-enabled/default" failed (2: No such file or directory) in /etc/nginx/nginx.conf:60
nginx: configuration file /etc/nginx/nginx.conf test failed

Here is nginx.conf:

user www-data;
worker_processes auto;
pid /run/;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;

http {
        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip on;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

Here is my website conf (/etc/nginx/sites-available/ledca.conf):

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/ledca/public;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        try_files $uri $uri/ =404;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;


Thank you for the feedback, Ansgar! This is what I see:

ubuntu@ip-172-31-1-135:~$ sudo ls -l /etc/nginx/snippets/fastcgi-php.conf
-rw-r--r-- 1 root root 423 Jul 27  2022 /etc/nginx/snippets/fastcgi-php.conf
ubuntu@ip-172-31-1-135:~$ sudo ls -l /var/www/ledca/public
total 12
drwxrwxr-x 3 www-data www-data 4096 Jun 24 21:27 build
-rwxrwxr-x 1 www-data www-data    0 Jun  7 13:20 favicon.ico
-rwxrwxr-x 1 www-data www-data 1710 Jun  7 13:20 index.php
-rwxrwxr-x 1 www-data www-data   24 Jun  7 13:20 robots.txt

So I need to get /etc/nginx/sites-enabled/default to link to /etc/nginx/sites-enabled/ledca.conf?


Executed these commands to resolve the issue:

ubuntu@ip-172-31-1-135:~$ sudo ls -l /etc/nginx/sites-enabled/ledca.conf /etc/nginx/sites-enabled/default
lrwxrwxrwx 1 root root 34 Jun 24 21:11 /etc/nginx/sites-enabled/default -> /etc/nginx/sites-available/default
lrwxrwxrwx 1 root root 37 Jun 25 02:20 /etc/nginx/sites-enabled/ledca.conf -> /etc/nginx/sites-available/ledca.conf
ubuntu@ip-172-31-1-135:~$ sudo sudo rm -rf /etc/nginx/sites-enabled/default
ubuntu@ip-172-31-1-135:~$ sudo sudo rm -rf /etc/nginx/sites-available/default
rwxrwxrwx 1 root root 37 Jun 25 02:20 /etc/nginx/sites-enabled/ledca.conf -> /etc/nginx/sites-available/ledca.conf
ubuntu@ip-172-31-1-135:~$ sudo ln -s /etc/nginx/sites-enabled/ledca.conf /etc/nginx/sites-available/default
ubuntu@ip-172-31-1-135:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
in Sysadmin
retagged by
by (15)
1 2
edit history
Please edit your question and show the content of the file /etc/nginx/sites-enabled/laravelapp.conf.
Your updated question says the error is in `/etc/nginx/sites-enabled/default`, but you're showing `/etc/nginx/sites-available/ledca.conf`. Is the former a symlink to the latter? If not, please show the file mentioned in the error message. Otherwise check if the 3 files/folders in the site config actually exist: `/var/www/ledca/public`, `/etc/nginx/snippets/fastcgi-php.conf`, `/var/run/php/php8.1-fpm.sock`. The 1st (webroot directory missing) and 3rd (php8.1-fpm service missing or not started) are probably the most likely candidates.

Please log in or register to answer this question.

1 Answer

0 votes

You don't need /etc/nginx/sites-enabled/default to link to /etc/nginx/sites-enabled/ledca.conf. Typically every vhost on a webserver is configured in a separate file in the sites-available subdirectory of your webserver's config directory. The vhosts that you want to publish are then symlinked from the sites-available into the sites-enabled directory. This approach is used so that you can enable/disable a vhost without actually having to remove its configuration from the config directory.

In your case default and ledca.conf were apparently different vhosts, and the issue was with the default vhost which you did not show, not with the vhost that you showed in your question. Removing the faulty vhost config would obviously resolve the problem, although I wouldn't recommend also removing the file from /etc/nginx/sites-available (it won't do any harm there).

by (125)
3 20 38
edit history