国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

單臺(tái)服務(wù)器中利用Apache的VirtualHost如、何搭建多個(gè)Web站點(diǎn)詳解

2019-11-02 14:29:02
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

前言

本文將詳細(xì)記錄一下如何在單臺(tái)服務(wù)器上,利用apache的virtualhost(虛擬主機(jī))來(lái)搭建多個(gè)不同的web站點(diǎn),并且每個(gè)站點(diǎn)獨(dú)立管理自己的session,下面話不多說(shuō)了,來(lái)一起看看詳細(xì)的介紹吧。

開發(fā)環(huán)境

先說(shuō)下我各項(xiàng)開發(fā)環(huán)境參數(shù):

操作系統(tǒng): RedHat6.7(CentOS) WEB服務(wù)器:apache2.2 php5.6.30

修改Apache配置

apache2.2 的配置文件路徑在 /etc/httpd/conf/httpd.conf

我們用下面的命令修改apache的配置文件:

$ vim /etc/httpd/conf/httpd.conf

添加監(jiān)聽端口

找到如下的部分,

## Listen: Allows you to bind Apache to specific IP addresses and/or# ports, in addition to the default. See also the <VirtualHost># directive.## Change this to Listen on specific IP addresses as shown below to# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)##Listen 12.34.56.78:80Listen 80

默認(rèn)的話,應(yīng)該只會(huì)監(jiān)聽80端口,這里我們?cè)诤竺婕由嫌糜诹硗庹军c(diǎn)的端口號(hào)。例如我們A站點(diǎn)是默認(rèn)的80端口,B站點(diǎn)計(jì)劃搭建在8080端口上,最終的配置文件修改成

...#Listen 12.34.56.78:80Listen 80Listen 8080

啟動(dòng)并添加VirtualHost

接著在配置文件中找到下面的章節(jié):

### Section 3: Virtual Hosts## VirtualHost: If you want to maintain multiple domains/hostnames on your# machine you can setup VirtualHost containers for them. Most configurations# use only name-based virtual hosts so the server 

上面的代碼是我已經(jīng)修改好的,默認(rèn)的話,最后兩行NameVirtualHost應(yīng)該也是被注釋掉了。 因?yàn)槲覀円獑⒂锰摂M主機(jī),所以這里就把我們之前監(jiān)聽的兩個(gè)端口都設(shè)置好。

同時(shí),將之后的配置文件修改成如下的樣子,我們先來(lái)設(shè)置默認(rèn)的80端口的站點(diǎn)A

## VirtualHost example:# Almost any Apache directive may go into a VirtualHost container.# The first VirtualHost section is used for requests without a known# server name.#<VirtualHost *:80># ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/webA ServerName webA# ErrorLog logs/dummy-host.example.com-error_log# CustomLog logs/dummy-host.example.com-access_log common</VirtualHost>

默認(rèn)的Apache是沒(méi)有開啟VirtualHost的,所以這些代碼都是被注釋掉了的,我們這里只需要把DocumentRoot和ServerName所在的行去掉注釋并且編輯下就好了。

DocumentRoot指的的是我們A站點(diǎn)的網(wǎng)站根目錄位置

接下來(lái)再補(bǔ)充上8080端口的B站點(diǎn)信息就好了。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 页游| 唐山市| 内丘县| 神木县| 镇平县| 全椒县| 晴隆县| 微博| 大新县| 广宁县| 铜梁县| 鸡东县| 镇远县| 大邑县| 西丰县| 石景山区| 手机| 宁南县| 宝坻区| 灯塔市| 通海县| 吴旗县| 抚州市| 松滋市| 航空| 惠水县| 庄浪县| 寿宁县| 沐川县| 武鸣县| 财经| 新闻| 博罗县| 温州市| 永州市| 万源市| 长丰县| 仙桃市| 蓝山县| 开化县| 内乡县|