萬盛學電腦網

 萬盛學電腦網 >> 服務器教程 >> linux下安裝apache詳解

linux下安裝apache詳解

  下面是linux下安裝apache的完整代碼,系統是redhat5.5

  下載httpd-2.2.6.tar.bz2 把httpd-2.2.6.tar.bz2放到/soft 下

  [root@localhost ~]#cd /soft

  [root@localhost soft]#tar jxvf httpd-2.2.6.tar.bz2 //解壓apache的壓縮包

  [root@localhost soft]#cd httpd-2.2.6 //定位到httpd-2.2.6 文件夾下

  [root@localhost httpd-2.2.6]#ls //查看顯示httpd-2.2.6 文件夾下內容

  [root@localhost httpd-2.2.6]#./configure --help | more //查看安裝apache配置參數

  [root@localhost httpd-2.2.6]#./configure --prefix=/usr/local/apache --enable-so // 配置apache路徑

  [root@localhost httpd-2.2.6]#make //編譯apache

  [root@localhost httpd-2.2.6]#make install //安裝apache

  [root@localhost httpd-2.2.6]#cd /usr/local/apache //進入apache的目錄

  [root@localhost apache]# cd conf/

  [root@localhost conf]#cp -a httpd.conf httpd.conf- //備份apache配置文件

  [root@localhost conf]#chkconfig --list httpd //查看httpd服務是否已存在

  [root@localhost conf]#chkconfig httpd off //關閉系統自帶了httpd的服務,如果存在httpd服務

  [root@localhost conf]#service httpd status //查看自帶httpd服務狀態

  [root@localhost conf]#/usr/local/apache/bin/apachectl -k start //linux啟動apache命令

  [root@localhost conf]#netstat -an | grep :80 //查看linux80端口是否開啟

  [root@localhost conf]#ps -aux | grep httpd //linux下查看apache進程

  [root@localhost conf]#cd ../..

  [root@localhost local]#cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache //拷貝apache啟動腳本

  [root@localhost local]#vi /etc/rc.d/init.d/apache // 這裡是編輯apache啟動腳本

  在開頭的#!/bin/sh 下面加上

  #chkconfig: 2345 85 15

  [root@localhost local]#chkconfig --add apache //添加apache服務

  [root@localhost local]#chkconfig --list apache //列出apache服務

  [root@localhost local]#service apache stop //停止apache服務

  [root@localhost local]#netstat -an | grep :80 //查看linux的80端口是否關閉

  [root@localhost local]#ps -aux | grep httpd //查看是否存在httpd服務,若果之前自帶httpd服務啟動的話會導致新添加的apache服務啟動失敗

  [root@localhost local]#service apache start //啟動apache服務

  打開你的服務器ip地址,看看是否出現了tomcat的默認首頁,如果出現的話,那麼恭喜你

  linux下安裝apache已經成功了

copyright © 萬盛學電腦網 all rights reserved