nginx error log was huge, so I deleted and created a new one, now nginx won't start

Solution 1:

This doesn't solve your problem, but in the future, if you do

cat /dev/null > /file/you/want/to/wipe-out

you will copy over the contents of the file with nothing, and keep all permissions in tact.

Not nginx-speicific, but Additionally, make sure you are running the application as the user it is supposed to run as. If you ever ran it as root, all the permissions are going to be owned by root, so other users won't be able to run it.

Solution 2:

The usual way to rotate the logs with NginX is to rename the file, and then /etc/init.d/nginx reload. The server starts a new file, and you can do what you wish with the old.

You may also find it useful to edit the configuration to not log as much....


Solution 3:

have a look in the nginx config, check who the server is running as - at a guess the user will be nginx

so :

chown nginx: /var/run/nginx.pid chown -R nginx: /var/log/nginx

Should do the trick.