Apache的虛擬機器主機配置和網頁加密

來源:互聯網
上載者:User

源碼安裝apache,在此略過

一:首先開啟虛擬機器主機功能

[root@localhost ~]# vim /usr/local/apache2/conf/httpd.conf

找到這一行,去掉前面的#號注釋(不同版本可能不在這一行)

460 #Include conf/extra/httpd-vhosts.conf

二:修改虛擬機器主機設定檔

網頁路徑在/usr/local/apache2/conf/htdocs下面

建立2個網站

建立2個網站的根目錄

mkdir /usr/local/apache2/htdocs/1 2

echo "woshi 1" > /usr/local/apache2/htdocs/1/index.html

echo "woshi 2" > /usr/local/apache2/htdocs/2/index.html

修改虛擬機器主機設定檔

[root@localhost ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf




啟動apache

/[root@localhost ~]# /usr/local/apache2/bin/apachectl restart

使用xp驗證:開啟c:/windows/system32/drivers/etc/hosts

添加兩行:

IP地址 www.1.com

IP地址 www.2.com



驗證:



OK 成功!


網頁加密



加密網站1的mimi這個頁面

echo "wo shi luo ben" > /usr/local/apache2/htdocs/1/mimi

修改虛擬機器主機設定檔,在末尾添加



其中.qq是一個建立的隱藏的檔案 放使用者資訊的檔案

接下來就是建立使用者

[root@localhost 1]# /usr/local/apache2/bin/htpasswd -c /usr/local/apache2/htdocs/1/.qq lin

New password:

Re-type new password:

Adding password for user lin

這個-c是建立.qq這個檔案的意思,第二個使用者就無需添加了,以為已經建立了

[root@localhost 1]# /usr/local/apache2/bin/htpasswd /usr/local/apache2/htdocs/1/.qq hh

New password:

Re-type new password:

Adding password for user hh

重啟apache

開啟瀏覽器看一下效果吧




Ok 大功告成!


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.