本篇博客爲構築LAMP架構第一步,安裝apache
實驗環境:redhat6.5
實驗目的:安裝apache
準備材料:redhat6.5系統 apache安裝包
實驗步驟:
輸入tar xzvf http-2.4.2.tar.gz -C /opt
tar xzvf apr-1.4.6.tar.gz -C /opt
tar xzvf apr-util-1.4.1.tar.gz -C /opt
依次安裝
輸入cp -R apr-1.4.6/ /opt/httpd-2.4.2/srclib/apr
cp -R apr-util-1.4.1/ /opt/httpd-2.4.2/srclib/apr-util
將兩個apr包複製進httpd中
輸入yum install gcc gcc-c++ make pcre pcre-devel -y
yum安裝前置包
輸入cd /opt/httpd-2.4.2 進入目錄
再輸入
./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi
運行 運行完畢如下圖
接下來輸入 make & make install 進行安裝
安裝完成如下圖
輸入grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd
並vi /etc/init.d/httpd 進行編輯
在文件最前面插入下面的行
#!/bin/sh
chkconfig:2345 85 15
# description:Apache is a World Wide Web server.
依次輸入
chmod +x /etc/init.d/httpd 給予運行權限
chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on 自啓動
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf 建立軟連接便於管理
vi /etc/httpd.conf 進行編輯
監聽本機的80端口
更改主機名
關掉防火牆,並重啓httpd服務
通過另一臺機器訪問本機IP,當顯示 It works! 時 則代表apache安裝成功