This is a new install in which nginx previously started and stopped normally. I believe this error arose after enabling server blocks which tested (nginx -t) successfully. I then tried to restart nginx and received this error:
nginx: [emerg] open() "/usr/share/nginx/on" failed (13: Permission denied)
The file "on" did not exist prior to the attempted restart. It was just created and is empty. When I restart php-fmp (successfully) and then try to restart nginx again, the error changes to:
nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
But again, when I run nginx -t, the test is successful:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
I thought it might be a user issue but everything seems fine:
# ps -elf | grep nginx
5 S nginx 2774 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www
5 S nginx 2775 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www
5 S nginx 2776 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www
5 S nginx 2777 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www
5 S nginx 2778 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www
0 R root 2940 2472 0 80 0 - 25811 - 22:18 pts/0 00:00:00 grep nginx
Even though Nginx is not running, the nginx.pid file remained so I deleted it. Doing so simply changed the error message back to:
nginx: [emerg] open() "/usr/share/nginx/on" failed (13: Permission denied) nginx: configuration file /etc/nginx/nginx.conf test failed.
This error was received regardless of how I tried to restart the system including $ sudo /etc/init.d/nginx restart
and $ sudo /etc/init.d/nginx reload
. I removed the empty "on" file which made no difference either. When I use $ getenforce
, it returns Enforcing
.
In response to @ǝɲǝɲbρɯͽ:
sudo grep -vR '^$\|^\s*\#' /etc/nginx/conf.d/* | grep -v ";"
and sudo grep -vR '^$\|^\s*\#' /etc/nginx/nginx.conf* | grep -v ";"
produced no missing semicolons.
The command sudo grep -ER "on|/usr/share" /etc/nginx/*
printed out nearly every line of every file in nginx so I'm not sure what I would learn from that information. Incidentally, /usr/shar/nginx
only contains that empty on
file, nothing else.
sudo ausearch -m avc -ts recent -c nginx
returned <no matches>
Needless to say, I am a newbie regarding server problems but I thought the command service --status-all
(below) may produce useful information. Of course, we already know that a pid file exists even though nginx is dead, but what is the master (pid 1924) is running
? Also, is there anything in the iptables that could be responsible for preventing nginx restart?
atd (pid 1995) is running...
auditd (pid 1405) is running...
crond (pid 1982) is running...
htcacheclean is stopped
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all ::/0 ::/0 state RELATED,ESTABLISHED
2 ACCEPT icmpv6 ::/0 ::/0
3 ACCEPT all ::/0 ::/0
4 ACCEPT udp ::/0 fe80::/64 state NEW udp dpt:546
5 ACCEPT tcp ::/0 ::/0 state NEW tcp dpt:22
6 REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
8 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
iscsi is stopped
iscsid is stopped
lvmetad is stopped
mdmonitor (pid 1445) is running...
multipathd is stopped
mysqld is stopped
netconsole module not loaded
Configured devices:
lo bond0 em1 em2
Currently active devices:
lo em1 em2 bond0
nginx dead but pid file exists
php-fpm is stopped
master (pid 1924) is running...
rdisc is stopped
restorecond is stopped
rsyslogd (pid 1425) is running...
sandbox is stopped
saslauthd is stopped
snmpd is stopped
snmptrapd is stopped
openssh-daemon (pid 1486) is running...
svnserve is stopped