Ubuntu/Centos 系統上安裝與配置Apache

來源:互聯網
上載者:User

標籤:nbsp   tables   etc   系統   修改   服務   線上安裝   alt   過程   

  一、線上安裝:

  Ubuntu:sudo apt-get install apache2

  Centos: sudo yum install apache2

二、安裝後的位置:

  1、服務地址:/etc/init.d/apache2

  2、配置地址:/etc/apache2/  如:/etc/apache2/apache2.conf

    

 

  3、Web預設目錄:/var/www/http/  如:/var/www/http/index.html

    

 

  4、日誌目錄:/var/log/apache2/  如:/var/log/apache2/access.log

    

 

  5、主程式檔案:/usr/sbin/apache2 

二、配置網站:

  1、簡單簡單介紹設定檔的功能:

    首先大家使用cd /etc/nginx 命令開啟到nginx的主配置目錄下,然後調用 ll 或 ls 列出目錄。

    

 

  2、比如我要配置下面兩個網站:

    (1)通過http://localhost:8080/ 訪問一個存放於磁碟位置:/var/www/html/ 下的網站。

    (2)通過http://localhost:8081/ 訪問一個存放於磁碟位置:/var/www/myweb/ 下的網站。

    實現過程:

    (1)開啟編輯:/etc/apache2/ports.conf 設定檔,添加兩個連接埠監聽:8081 和 8080。

      

 

    (1)開啟cd到/etc/apache2/sites-available目錄,使用sudo vim ./000-default.conf 來修改該目錄下的設定檔:

      將配置資訊修改為所示即可。

      

 

    (2)、儲存設定檔:按 Ecs 退出編輯狀態。Shift+:出現命令列時,輸入wq!即可儲存。如果提示是一個唯讀檔案無法儲存時,只需要使用sudo命令重新vi編輯一上一步驟即可。

三、啟動服務:

  輸入命令: sudo systemctl restart apache2.service   

  或者:sudo service apahce2 restart  

  啟動即可。

 

      

 四、訪問測試效果:

  1、如果想讓外網訪問,需要關閉防火牆。方法:sudo iptables -F   

  2、效果:

  測試8080連接埠:

   

  測試8081連接埠:

  略。

 

  

 

 

  

Ubuntu/Centos 系統上安裝與配置Apache

聯繫我們

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