Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

On my linux PC, I'd like to run nginx as whatever user I'm logged into when I start it, and I'd like it to look for config files in the home directory of that user.

Is there a way to install nginx to do this instead of always running as the same user (e.g. the nginx user) and looking to some config directory in /etc or /usr?

share|improve this question

If the configuration folders are hard-coded, (meaning no command line parameters available to change them), you'll have to compile it yourself and change the parameters using --prefix etc.

share|improve this answer

Of course there is.

You create a nginx.conf file in your home directory with similar content (replace [USERNAME] by your login):

error_log /home/[USERNAME]/nginx.log;
pid        /home/[USERNAME]/;

http {
    include  /etc/nginx/mime.types;
    index   index.php;
    client_body_temp_path /home/[USERNAME]/tmp;
    proxy_temp_path /home/[USERNAME]/tmp;
    fastcgi_temp_path /home/[USERNAME]/tmp;
    uwsgi_temp_path /home/[USERNAME]/tmp;
    scgi_temp_path /home/[USERNAME]/tmp;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for" "$http_cookie" "$sent_http_content_type"';

    access_log  /home/[USERNAME]/nginx-access.log  main  buffer=32k;

    gzip  on;

    server {
        listen       1234;
        root    /home/[USERNAME]/public_html;
        index index.php;


And then run /usr/sbin/nginx -c /home/[USERNAME]/nginx.conf - it will start server for your user. Remember that only root can bind to ports below 1024 (i.e. 80). You will have to configure the server to listen on some other port.

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.