问题描述
使用nginx的基本安装,您的sites-available
文件夹只有一个文件:default
With the base install of nginx, your sites-available
folder has just one file: default
sites-available
文件夹如何工作,我将如何使用它托管多个(单独的)网站?
how does the sites-available
folder work and how would I use it to host multiple (separate) websites?
推荐答案
只需添加另一种方法,您就可以为托管的每个虚拟域或站点使用单独的文件.您可以将默认副本作为每个副本的起点,并为每个站点进行自定义.
然后在启用站点的站点中创建符号链接.这样,您可以通过添加或删除符号链接并发布服务nginx重新加载来访问站点.
Just to add another approach, you can use a separate file for each virtual domain or site you're hosting.You can use a copy of default as a starting point for each one and customize for each site.
Then create symlinks in sites-enabled. In this way you can take sites up and down just by adding or removing a symlink and issuing a service nginx reload.
在进行网站维护时,您可以发挥创意并使用此方法将网站重定向到维护模式页面.
You can get creative and use this method to redirect sites to a maintenance mode page while you are doing site maintenance.
所以结构看起来像这样:
So the structure looks like this:
/sites-available/ (you can use obvious file names like this)
|
|-> a.mysite.com
|-> b.mysite.com
|-> someOtherSite.com
/sites-enabled/ (these are just symlinks to the real files in /sites-available)
|
|-> a.mysite.com
|-> b.mysite.com
请注意,由于只有前两个条目是sites-enabled
中唯一的符号链接项目,因此第三个条目someOtherSite.com
处于脱机状态.
Notice that since there are only the first two entries are the only symlinked items in sites-enabled
, the third entry, someOtherSite.com
is therefore offline.
这篇关于nginx&上的多个网站网站可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!