nginx & 上的多个网站可用站点 [英] multiple websites on nginx & sites-available

查看:21
本文介绍了nginx & 上的多个网站可用站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 nginx 的基础安装,您的 sites-available 文件夹只有一个文件:default

sites-available 文件夹如何工作,我将如何使用它来托管多个(单独的)网站?

解决方案

只是添加另一种方法,您可以为您托管的每个虚拟域或站点使用单独的文件.您可以使用默认副本作为每个站点的起点,并为每个站点进行自定义.
然后在启用站点的地方创建符号链接.通过这种方式,您可以通过添加或删除符号链接并发出服务 nginx 重新加载来上下移动站点.

在进行网站维护时,您可以发挥创意并使用此方法将网站重定向到维护模式页面.

所以结构看起来像这样:

/sites-available/(你可以使用这样明显的文件名)||->a.mysite.com|->b.mysite.com|->someOtherSite.com/sites-enabled/(这些只是指向/sites-available 中真实文件的符号链接)||->a.mysite.com|->b.mysite.com

请注意,由于 sites-enabled 中只有前两个条目是唯一的符号链接项,因此第三个条目 someOtherSite.com 处于离线状态.>

With the base install of nginx, your sites-available folder has just one file: default

how does the sites-available folder work and how would I use it to host multiple (separate) websites?

解决方案

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

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 & 上的多个网站可用站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆