简体   繁体   English

NGINX - 将根目录设置为子目录

[英]NGINX - Set root to sub directory

I use Trellis from the Roots.io WordPress framework stack.我使用来自Roots.io WordPress 框架堆栈的格子 It sets up a LEMP environment for me.它为我设置了一个 LEMP 环境。

The nginx root path is set to: root /srv/www/example.co.uk/current/web; nginx根路径设置为: root /srv/www/example.co.uk/current/web;

  • Inside the /web directory is a directory called /static . /web目录内部是一个名为/static的目录。

Long story short.长话短说。 I want all traffic to be sent to the /srv/www/example.co.uk/current/web/static directory.我希望将所有流量发送到/srv/www/example.co.uk/current/web/static目录。 So it acts like /static is the root and loads the website from there.所以它就像 /static 是根目录并从那里加载网站。

Resolved.解决。

Have a read of the Nginx includes docs.阅读 Nginx 包括文档。 https://roots.io/docs/trellis/master/nginx-includes/#child-templates https://roots.io/docs/trellis/master/nginx-includes/#child-templates

Create the following directory and file (per site) inside of Trellis.在 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 .更新mysite.co.uk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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