1. 程式人生 > >LAMP架構(1)-安裝apache

LAMP架構(1)-安裝apache

Redhat apache

本篇博客為構築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安裝成功
技術分享圖片

LAMP架構(1)-安裝apache