centos-6.5 安裝apache

來源:互聯網
上載者:User

標籤:

1、避免連接埠、程式衝突、使用rpm卸載httpd

[[email protected] /]# rpm -qa httpd        #檢查httpd的包[[email protected] /]# rpm -e httpd --nodeps    #卸載

2、源碼編譯安裝

  • 下載httpd包、解壓
[[email protected] /]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.gz[[email protected] /]# tar zxf httpd-2.2.31.tar.gz -C /usr/src   #解壓到/usr/src[[email protected] /]# cd /usr/src/httpd-2.2.31/

 

  • 配置
[[email protected] httpd-2.2.31]# ls INSTALL README  #遇到不熟悉的軟體是可參考這兩個檔案[[email protected] httpd-2.2.31]# less README[[email protected] httpd-2.2.31]# less INSTALL [[email protected] httpd-2.2.31]# ./configure --help  #各種配置選項及含義[[email protected] httpd-2.2.31]# yum -y install gcc[[email protected] httpd-2.2.31]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi--prefix  #安裝目錄--enable-so  #啟用載入狀態模組--enable-rewrite  #啟用網頁地址修正功能--enable-charset-lite  #啟用字元集支援--enable-cgi  #啟用CGI指令碼程式支援[[email protected] httpd-2.2.31]# echo $?0

 

  • 編譯安裝
[[email protected] httpd-2.2.31]# make && make install   # make進行編譯、make install 安裝[[email protected] httpd-2.2.31]# echo $?0

 

3、確認安裝結果

[[email protected] httpd-2.2.31]# ls /usr/local/httpd/bin    cgi-bin  error   icons    lib   man     modulesbuild  conf     htdocs  include  logs  manual

 

4、最佳化執行路徑

[[email protected] httpd-2.2.31]# ln -s /usr/local/httpd/bin/* /usr/local/bin/[[email protected] httpd-2.2.31]# ls -l /usr/local/bin/httpd /usr/local/bin/apachectl lrwxrwxrwx. 1 root root 30 Sep 27 23:49 /usr/local/bin/apachectl -> /usr/local/httpd/bin/apachectllrwxrwxrwx. 1 root root 26 Sep 27 23:49 /usr/local/bin/httpd -> /usr/local/httpd/bin/httpd

 

5、添加httpd系統服務

[[email protected] httpd-2.2.31]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd[[email protected] httpd-2.2.31]# vim /etc/init.d/httpd #!/bin/sh# chkconfig:35 85 21  #3、5中啟動、啟動關閉的順序分別為85、21# description: start Apache HTTP Server  #服務描述[[email protected] httpd-2.2.31]# chkconfig --add httpd  #添加系統服務ch[[email protected] httpd-2.2.31]# chkconfig --list httpd   #查看httpd服務的自啟動狀態httpd              0:off    1:off    2:off    3:on    4:off    5:on    6:off

 

6、配置httpd服務、並啟動

[[email protected] httpd-2.2.31]# vim /usr/local/httpd/conf/httpd.confServername www.httpd.com[[email protected] httpd-2.2.31]# /usr/local/httpd/bin/apachectl -t #語法檢查Syntax OK[[email protected] httpd-2.2.31]# /etc/init.d/httpd start[[email protected] httpd-2.2.31]# netstat -anpt | grep httpdtcp        0      0 :::80                       :::*                        LISTEN      50141/httpd     

 

7、訪問web網站

[[email protected] httpd-2.2.31]# vim /etc/hosts192.168.119.131  www.httpd.com[[email protected] httpd-2.2.31]# curl www.httpd.com<html><body><h1>It works!</h1></body></html>

 

8、查看web網站訪問情況

訪問日誌access_log錯誤記錄檔error_log[[email protected] httpd-2.2.31]# tail /usr/local/httpd/logs/access_log 192.168.119.131 - - [28/Sep/2016:00:05:13 +0800] "GET / HTTP/1.1" 200 44[[email protected] httpd-2.2.31]# tail /usr/local/httpd/logs/error_log

 

centos-6.5 安裝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.