Error with Nginx
When running an Nginx test, the following response was being presented:
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2022/08/04 07:05:54 [warn] 3105#3105: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2022/08/04 07:05:54 [crit] 3105#3105: pread() "/etc/nginx/sites-enabled/ckan" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
Permission issue
This error is shown because the user executing Nginx does not have permission to view the log file created by the Nginx process, which is most likely owned by www-data and not the user. Running the command with sudo, if possible, or giving the user permissions on the error log will eliminate the error message being shown.
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
First, try the access rights to the folder and files for Nginx (www-data user in my case):
sudo chown -R www-data:www-data /var/log/nginx
Or if you want you can remove the directory and rebuild:
sudo rm -rf /var/log/nginx
sudo mkdir /var/log/nginx
sudo touch /var/log/nginx/error.log
sudo chown -R www-data:www-data /var/log/nginx
Critical issue
2022/08/04 07:05:54 [crit] 3105#3105: pread() "/etc/nginx/sites-enabled/ckan" failed (21: Is a directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
In this instance, pread() which 'pread, pwrite - read from or write to a file descriptor at a given offset'. So it attempting to read a file. However, reviewing the structure on this path "/etc/nginx/sites-enables/ckan" I found that it's a directory. In this directory, there is a file nginx.conf.
ckan -> /etc/nginx/sites-available/ckan/nginx.conf
default -> /etc/nginx/sites-available/default
One approach is to change the symlink to the file. Take the following steps
Rename the ckan directory to something else
sudo mv ckan ckan-cc
Move the conf file and rename it
sudo mv ckan-cc/nginx.conf ckan
If you need to re-map the symlink, then run the command From the sites-enabled directory run the following command
ln -s ../sites-available/ckan
Test
Test Nginx configuration by running the command
nginx -t -c /etc/nginx/nginx.conf
or simply
nginx -t
My response was:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful