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

首頁 > 網(wǎng)站 > Apache > 正文

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

2024-08-27 18:24:10
字體:
供稿:網(wǎng)友
這篇文章主要給大家介紹了關(guān)于在單臺(tái)服務(wù)器中利用Apache的VirtualHost如何搭建多個(gè)Web站點(diǎn)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。

前言

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

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

先說下我各項(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 doesn't need to worry about# IP addresses. This is indicated by the asterisks in the directives below.## Please see the documentation at# <URL:http://httpd.apache.org/docs/2.2/vhosts/># for further details before you try to setup virtual hosts.## You may use the command line option '-S' to verify your virtual host# configuration.## Use name-based virtual hosting.# NameVirtualHost *:80 NameVirtualHost *:8080

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

同時(shí),將之后的配置文件修改成如下的樣子,我們先來設(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>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 广水市| 武邑县| 工布江达县| 寻甸| 临西县| 扎鲁特旗| 陆良县| 平和县| 名山县| 汨罗市| 彩票| 宁陵县| 翁牛特旗| 六盘水市| 乐山市| 海安县| 苍山县| 新宾| 北宁市| 石狮市| 湄潭县| 夹江县| 分宜县| 六盘水市| 彰化县| 桂林市| 佛山市| 安平县| 平度市| 泰州市| 永济市| 常宁市| 黔东| 无为县| 甘肃省| 平安县| 秦皇岛市| 凤冈县| 磴口县| 山东| 崇左市|