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/nginx.pid;

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!

  • Perhaps you could snip less of your startup script? It looks like it's testing the wrong config file. Sep 7, 2011 at 12:59

2 Answers 2


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

You can find this in here: http://wiki.nginx.org/CoreModule 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) "

  • This is true, but how can this be solved? (How to run nginx as non-root?) Mar 14, 2012 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, 2015 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .