简体   繁体   中英

NGINX - Set root to sub directory

I use Trellis from the Roots.io WordPress framework stack. It sets up a LEMP environment for me.

The nginx root path is set to: root /srv/www/example.co.uk/current/web;

  • Inside the /web directory is a directory called /static .

Long story short. I want all traffic to be sent to the /srv/www/example.co.uk/current/web/static directory. So it acts like /static is the root and loads the website from there.

Resolved.

Have a read of the Nginx includes docs. https://roots.io/docs/trellis/master/nginx-includes/#child-templates

Create the following directory and file (per site) inside of Trellis.
/trellis/nginx-includes/mysite.co.uk.conf.child

{% extends 'roles/wordpress-setup/templates/wordpress-site.conf.j2' %}

{% block change_nginx_root_path %}

# Change NGINX root path
root /srv/www/mysite.co.uk/current/web/static;

{% endblock -%}

Update the mysite.co.uk .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM