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

首頁 > 網站 > Apache > 正文

apache實現部署多個網站(一個ip部署多域名)的方法詳解

2024-08-27 18:24:08
字體:
來源:轉載
供稿:網友
最近去機房幫別人配置網站,機房的服務器本身已經搭建了一個網站,我們需要再配置一個,所以記錄下來,這篇文章主要給大家介紹了關于apache如何實現部署多個網站(一個ip部署多域名)的相關資料,需要的朋友可以參考借鑒,下面來一起看看吧。

前言

在日常的網站發布中很多情況下都無法做到一個IP對應一個站點,在IP4的情況下IP的資源是相對有限的。然而作為最流行的Apache自然也考慮到這種情況,下面來一起看看詳細的介紹吧。

配置方法

首先apache的版本是2.4.7,然后系統是Ubuntu 14.04.1 LTS。(因為好像配置文件和目錄有差異)

首先進到apache2目錄下,


我們要探討的主要是sites-available和sites-enabled根據字面意思,前一個是網站可用的,后一個是網站可用的,然后我們還知道了,sites-enabled里面的文件是sites-available里面文件的軟鏈接,所以我們主要改site-available的文件,打開site-available有兩個文件,但我們只需要000-default.conf文件,打開cat文件

代碼如下:

<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must seothert it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/ # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf</VirtualHost>

這就是網址配置文件了,而我們要修改的只有被注釋掉的ServerName 域名,DocumentRoot 路徑這兩個部分,去掉注釋剩下。

<VirtualHost *:80> ServerName #這里是域名地址 ServerAdmin webmaster@localhost DocumentRoot /var/www/  #這里是路徑 ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>

可以直接添加在下面,重啟apache就成了。但是上面的優先級要更高,訪問自己的域名會跳轉到你設置的路徑,直接訪問ip還是會到第一個設置的路徑,你也可以選擇刪除。

還有另外一種改法就是新建一個文件,xxx.conf然后內容一樣,

<VirtualHost *:80> ServerName #這里是域名地址 ServerAdmin webmaster@localhost DocumentRoot /var/www/  #這里是路徑 ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台东县| 刚察县| 西丰县| 杭锦后旗| 惠来县| 桂林市| 平江县| 安化县| 天气| 黄石市| 图木舒克市| 岢岚县| 泗阳县| 苍溪县| 施甸县| 亳州市| 桦南县| 高清| 保山市| 定兴县| 恩施市| 凉山| 高陵县| 溧阳市| 武平县| 堆龙德庆县| 隆化县| 安远县| 长沙县| 浙江省| 沙湾县| 永宁县| 晴隆县| 玉溪市| 瓦房店市| 高雄县| 阜宁县| 海伦市| 休宁县| 新安县| 巴东县|