Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am on a shared host with rights to inherit the nginx root installation and overriding it's config file (note: I do NOT want to compile my own nginx in my home directory).

I wrote a start/reload/stop script which works perfectly however I keep getting the error below

the startup script


# Set this to your nginx configuration file and PID


# Do not change anything below unless you know what you do



My config:

worker_processes  4;

error_log  /home/myusername/nginx/error.log;
pid        /home/myusername/nginx/;

events {
    worker_connections  8192;
    multi_accept on;
    use epoll;

http {
    error_log /home/myusername/nginx/error.log;
    access_log /home/myusername/nginx/access.log;
    server_names_hash_max_size 8192;
    server_names_hash_bucket_size 128;
    include       /etc/nginx/mime.types;
    underscores_in_headers on;

The error:

Reloading nginx configuration: [alert]: could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)

So it seems it's not reading my error and acces log locations correctly, how do I solve this, thanks!

share|improve this question
Perhaps you could snip less of your startup script? It looks like it's testing the wrong config file. – Martin Fjordvald Sep 7 '11 at 12:59

NGINX searches for the built-in error log location, before it reads your config file.

You can find this in here: under the error_log section.

"Also note that as of version 0.7.53, nginx will use a compiled-in default error log location until it has read the config file. If the user running nginx doesn't have write permission to this log location, nginx will raise an alert like this:

[alert]: could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) "

share|improve this answer
This is true, but how can this be solved? (How to run nginx as non-root?) – Etienne Perot Mar 14 '12 at 15:01
You'll need to change the permissions on the compiled-in location, or else rebuild the binary to change the compiled-in location. – womble Oct 5 '15 at 6:46

I've been able to get this to work using the -p option, setting the prefix to a path I can write to.

$ nginx -p . -c my-nginx.conf
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.