apache編譯安裝

httpd編譯安裝:
防止受selinux影響,先關閉selinux:
   1.setenforce 0 關閉selinux   [getenforce查看]  臨時關閉selinux
   2.永久關閉: vim  /etc/sysconfig/selinux   --> SELINUX=disable 
一.解壓源碼包:
  tar xf httpd-2.2.19.tar.bz2
  cd httpd-2.2.19
二.配置安裝:
   ./configure --prefix=/usr/local/apache --enable-ssl --enable-so \
   --sysconfdir=/etc/httpd --enable-modules=most --enable-mods-shared=most
 
   make && make installlinux

三.準備服務腳本 (準備一個完整的httpd腳本)
   編輯 httpd
   1.將check函數刪除
   2.apachectl=後改成: /usr/local/apache/bin/apachectl 
     httpd=後改成: ${HTTPD-/usr/local/apache/bin/httpd}
     pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
   3.複製到服務目錄:
    cp httpd /etc/init.d/
    (要給此文件加上執行權限)
   4.加入服務列表:  (要等apache安裝結束)
    chkconfig --add httpd
    chkconfig httpd on
   5.啓動
    service httpd start
四.驗證安裝:
    在瀏覽器裏輸入虛擬機地址後顯示"It works!"則代表成功
五.編輯配置文件
    cd /etc/httpd
    cp  httpd.conf httpd.conf.2 (備份前備份配置文件)
    vim http.conf
      1.註釋中心主機
       在DocumentRoot "..." 行前加"#"
      2.啓用虛擬主機
       將"# Virtual hosts"行 下 "Include ..."行前"#"去除.
      3.編輯虛擬主機設置:
       vim /etc/httpd/extra/httpd-vhosts.conf
例:
<VirtualHost *:80>
    ServerAdmin durpal@a.com
    DocumentRoot "/web/web1"
    ServerName www.a.com
    ErrorLog "logs/durpal-error_log"
    CustomLog "logs/durpal-access_log" common
    <Directory "/web/we1"
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
    </Directory>
</VirtualHost>web

   [注:DocumentRoot,ServerName定義的目錄,根據狀況自行創建]apache

六.創建目錄
   mkdir -pv /web/web1
七.配置PATH
   vim /etc/profile
   添加:PATH=$PATH:/usr/local/apache/bin
  vim

相關文章
相關標籤/搜索