RedHat Linux 9.0下Apache 2.2安裝及簡單配置

來源:互聯網
上載者:User

環境:虛擬機器VMware Workstation 7.1+RedHat Linux 9.0

安裝步驟:

1.下載apache2.2.18.tar.gz安裝包;

2.複製到根目錄:#cp apache2.2.18.tar.gz ~

3.進入根目錄,解壓:cd 斷行符號;tar -xvzf apache2.2.18.tar.gz 解壓

4進入apache2.2.18目錄

5.用以下命令安裝:#./configure --prefix=/usr/local/apache2  ——這就是安裝目錄了

                                #make

                               #make install

6.進入apache安裝目錄:cd /usr/local/apache2/bin   啟動apache服務:sh apachectl start

7.測試是否成功,瀏覽器輸入http://serverip 顯示 it works成功

簡單配置:

 1.進入目錄:cd /usr/local/apache2/conf

2.編輯設定檔httpd.conf  : vi httpd.conf

3.輸入 /ServerName 斷行符號定位到ServerName位置,修改主機名稱 ServerName 192.168.223.137:80 ( 註:此ip地址為自己機子的)儲存退出:wq

4.進入目錄:/usr/local/apache2/htdocs 修改index.html檔案

5.修改hosts檔案:vi /etc/hosts 添加 192.168.223.137  linuxidc.net ---隨便輸用它登入

6.若在windows下登入還得修改win下hosts檔案: %systemroot%3/windows/system32/drivers/etc 用記事本開啟修改添加即可

7.IE中輸入http://www.myhack58.net,將顯示第4步修改的index.html 網頁

註:登入中有可能無法顯示。可以關閉linux防火牆:service iptables stop即可

關於虛擬機器主機的配置:

 主要設定檔位於:/usr/local/apache2/conf/extra目錄下的httpd-vhosts.conf檔案

前提:1.在主設定檔httpd.conf中把 Include conf/extra/httpd-vhosts.conf 這行注釋去掉;

        2.<Directory>與 </Directory> 間的內容注釋掉,即前加#

        3.以不同網域名稱區分虛擬機器主機如:www.2cto.com及 ww.myhack58.net.

具體步驟:

1.進入/usr/local/apache2/conf/extra目錄編輯httpd-vhosts.conf檔案或自己建立一個,先備份原檔案

2.備份原檔案:cp httpd-vhosts.conf httpd-vhosts.conf.bak

3.編輯httpd-vhosts.conf:vi httpd-vhosts.conf

4.修改內容:

NameVirtualHost 192.168.223.137:80


<VirtualHost 192.168.223.137:80>
     ServerName www.2cto.com
     DocumentRoot  "/usr/local/apache2/htdocs/www.2cto.com"——如果目錄不存在先建個
     Directoryindex  index.html——此檔案自己建個在www.2cto.com目錄下
  
    <Directory "/usr/local/apache2/htdocs/www.2cto.com">

        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 192.168.223.137:80>
     ServerName www.myhack58.net
     DocumentRoot  "/usr/local/apache2/htdocs/www.myhack58.net"——如果目錄不存在先建個
     Directoryindex  index.html——此檔案自己建個在www.myhack58.net目錄下
  
    <Directory "/usr/local/apache2/htdocs/www.myhack58.net">
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

5.儲存退出,重啟服務

   /usr/local/apache2/bin/apachectl stop

   /usr/local/apache2/bin/apachectl start

6.在/etc/hosts及windows下的hosts檔案中添加網域名稱解析

192.168.223.137  www.2cto.com

192.168.223.137  www.myhack58.net

7.瀏覽器中分別輸入www.2cto.com及  www.myhack58.net顯示不同網頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.