Skip to content

Nginx

Begining

  1. Beginging Beginging
  2. Nginx Doc https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/
  3. server_name 限制存取 clients http://nginx.org/en/docs/http/server_names.html
  4. Sone Nginx setting https://pvera.net/posts/create-site-nginx-hugo/

Way 1 : Run nginx as the user as the '/root/downloads/boxes/' owner

In nginx.conf :

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
YES, in the first line "#user noboy;" , just delete "#" , and change "nobody" to your own username in Linux/OS X, i.e change to "root" for test. The restart nginx.

Attention , You'd better not run nginx as root! Here just for testing, it's dangerous for the Hacker.

For more reference , see nginx (engine X) – What a Pain in the BUM! [13: Permission denied]

Way 2 : Change '/root/downloads/boxes/' owner to 'www-data' or 'nobody'

In Terminal:

ps aux | grep nginx
Get the username of running nginx . It should be 'www-data' or 'nobody' determined by the version of nginx. Then hit in Terminal(use 'www-data' for example):

chown -R www-data:www-data /root/downloads/boxes/

------------------------------One More Important Thing Is:------------------------------

These parent directories "/", "/root", "/root/downloads" should give the execute(x) permission to 'www-data' or 'nobody'. i.e.

ls -al /root
chmod o+x /root
chmod o+x /root/downloads