欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ubuntu 14.04設置Apache虛擬主機的方法

  發(fā)布時間:2015-04-07 14:34:13   作者:佚名   我要評論
使用Ubuntu 14.04 32位 LTS,并搭建2個測試網站分別命名為“unixmen1.local” 和 “unixmen2.local”.我的測試機分別為192.168.1.250/24和server.unixmen.local。你可以根據你的需要更改虛擬域名

  在這個教程中,我會使用Ubuntu 14.04 32位 LTS,并搭建2個測試網站分別命名為“unixmen1.local” 和 “unixmen2.local”.我的測試機分別為192.168.1.250/24和server.unixmen.local。你可以根據你的需要更改虛擬域名。

  安裝Apache網站服務器

  安裝apache服務器之前,我們來更新一下我們的Ubuntu服務器:

  sudo apt-get update然后,用下面命令來安裝apache網絡服務器:

  sudo apt-get install apache2安裝apache服務器之后,讓我們通過這個URL http://你的服務器的IP地址/ 來測試網站服務器是否正常工作

ubuntu 14.04設置Apache虛擬主機的方法 三聯

  如你所見,apache服務器已經工作了。

  設置虛擬主機

  1.創(chuàng)建虛擬目錄

  現在,讓我們繼續(xù)安裝虛擬主機。正如我先前所述,我要新建2臺虛擬主機分別命名為“unixmen1.local”和“unixmen2.local”.

  創(chuàng)建一個公用的文件夾來存放這兩臺虛擬主機的數據。

  首先,讓我們?yōu)閡nixmen1.local這個站點創(chuàng)建一個目錄:

  sudo mkdir -p /var/www/unixmen1.local/public_html接著,為for unixmen2.local站點創(chuàng)建一個目錄:

  sudo mkdir -p /var/www/unixmen2.local/public_html

  2. 設置所有者和權限

  上面目錄現在只有root擁有權限。我們需要修改這2個目錄的擁有權給普通用戶,而不僅僅是root用戶。

  sudo chown -R $USER:$USER /var/www/unixmen1.local/public_html/

  sudo chown -R $USER:$USER /var/www/unixmen2.local/public_html/

  “$USER”變量指向了當前的登錄用戶。

  設置讀寫權限給apache網頁根目錄(/var/www)及其子目錄,這樣每個人都可以從目錄中讀取文件。

  sudo chmod -R 755 /var/www/這樣,我們就創(chuàng)建好了一些文件夾來保存網絡相關數據并分配必要的權限和所屬用戶。

  4. 為虛擬主機創(chuàng)建示例頁

  現在,我們給網站增加示例頁。第一步,讓我們給虛擬主機unixmen1.local創(chuàng)建一個示例頁。

  給unixmen1.local虛擬主機創(chuàng)建一個示例頁,

  sudo vi /var/www/unixmen1.local/public_html/index.html添加以下內容:

  XML/HTML Code復制內容到剪貼板

  Welcome To Unixmen1.local website

  保存并關閉文件。

  同樣的,添加示例頁到第二臺虛擬主機。

  sudo vi /var/www/unixmen2.local/public_html/index.html添加以下內容:

  復制代碼

  代碼如下:

  Welcome To Unixmen2.local website

  保存并關閉文件。

  5. 創(chuàng)建虛擬主機配置文件

  默認情況下,apache有一個默認的虛擬主機文件叫000-default.conf。我們將會復制000-default.conf文件內容到我們新的虛擬主機配置文件中。

  sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/unixmen1.local.conf

  sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/unixmen2.local.conf確保虛擬主機配置文件末尾包含.conf擴展名。

  現在,修改unximen1.local.conf文件以符合需求。

  sudo vi /etc/apache2/sites-available/unixmen1.local.conf使相關的變化直接呈現在unixmen1站點中(譯注:以“#”開頭的注釋行可以忽略。)。

  復制代碼

  代碼如下:

  # 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 set it for any further virtual host explicitly.

相關文章

最新評論