Linux 環境下手工編譯安裝Apache
實驗準備:
1.VMwore 12 環境下Red Hat 6.5版本虛擬機一臺
2.相關軟件包:apr、apr-util、httpd
備註:apache官網下載http://www.apache.org/ 將實驗所需的軟件包下載好,並解壓到指定文件夾
``
一、Apache安裝
1.首先解壓軟件包http、apr、apr-util(支持Apache上層應用跨平臺,提供底層接口庫)至/opt目錄下
tar xzvf http-2.4.2.tar.gz -C /opt
tar xzvf apr-1.4.6.tar.gz -C /opt
(支持Apache上層應用跨平臺,提供底層接口庫)tar xzvf apr-util-1.4.1.tar.gz -C /opt
2.進入軟件包目錄,將apr和apr-util包復制到httpd目錄下
cp -R apr /opt/httpd-2.4.2/srclib/apr
cp -R apr-util /opt/httpd-2.4.2/srclib/apr-util
3.安裝 gcc 、 gcc-c++ 、 make 、 pcre、pcre-devel 四個包
yum install gcc gcc-c++ make pcre pcre-devel -y
4.進入httpd目錄下,配置configure
cd /opt/httpd-2.4.2
5.配置
./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi
6.編譯及安裝
make && make install
7.過濾掉註釋行(#)並復制 httpd服務文件到/etc/init.d/
grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd
8.修改配置文件vim /etc/init.d/httpd 在文章的最下面插入下面的行
#!/bin/sh
chkconfig:2345 85 15
description:Apache is a World Wide Web server
9.給httpd文件添加執行權限
chmod +x /etc/init.d/httpd
10.添加httdp服務,設置為init3、init5 時開機自啟動。
chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on
11.建立/etc/httpd.conf文件的軟鏈接,便於後期管理
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
12.修改配置文件httpd.conf
vim /etc/httpd.conf
Listen:#監聽IP地址,這裏修改為自己的本地IP地址。
ServerName:主機名.域名
13.重啟httpd服務
service httpd shop
service httpd start
14.關閉防火墻
service iptables stop
setenforce 0
最終測試
如果出現上圖界面就說明Apache已經安裝成功了,另外主頁存放路徑為 /usr/local/apache/htdocs/index.html 可以在編輯此文件修改主頁上的內容
Linux 環境下手工編譯安裝Apache