1. 程式人生 > >Apache手工編譯安裝(內附軟件包)

Apache手工編譯安裝(內附軟件包)

良好的 https 51cto apr-util cli rem init.d lib term

Apache http server 是開源軟件的傑出代表,基於標準的HTTP網絡協議提供網頁瀏覽服務,apache服務器可以運行在Linux UNIX Windows等多種操作系統平臺。

Apache的主要特點

  • 開放源代碼
  • 跨平臺應用
  • 支持各種Web編程語言
  • 模塊化設計
  • 運行非常穩定
  • 良好的安全性

環境部署

  • redhat6.5系統
  • ip地址:192.168.100.101
  • 相關軟件包:百度雲

1.查看系統是否安裝httpd服務,如有卸載。

# rpm -q httpd
httpd-2.2.15-29.el6_4.x86_64
# yum remove httpd -y 

2.創建一個目錄,掛載宿主機上的共享出來的apache軟件包

# mkdir /abc
# mount.cifs //192.168.100.3/linux /abc
# ls /abc/LAMP
apr-1.4.6.tar.gz                 
apr-util-1.4.1.tar.gz
httpd-2.4.2.tar.gz

3.解壓Apache壓縮包到/opt下

# tar zxvf httpd-2.4.2.tar.gz -C /opt
# tar zxvf apr-1.4.6.tar.gz -C /opt
# tar zxvf apr-util-1.4.1.tar.gz -C /opt

4.將解壓後的包復制到/opt/httpd-2.4.2/srclib下分別改名為apr和apr-util

# cp -R apr-1.4.6/ httpd-2.4.2/srclib/apr
# cp -R apr-util-1.4.1/ httpd-2.4.2/srclib/apr-util

5.yum安裝相關環境包

# yum install gcc gcc-c++ make perl pcre-devel expat-devel libxml2-devel -y

6.配置軟件模塊

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

配置信息

./configure --prefix=/usr/local/apache \      安裝路徑
--enable-so \                     啟動內核
--enable-rewrite \                啟動重寫功能
--enable-mods-shared=most \       模塊共享
--with-mpm=worker \               用戶多進程
--disable-cgid \                  通用網關接口
--disable-cgi

7.編譯安裝

# make && make install

8.過濾apachectl的# 重定向保存到/etc/init.d/httpd中 (啟動腳本)

 # 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.

9.給httpd腳本開啟執行權限、添加服務

# chmod +x /etc/init.d/httpd    //給httpd開啟執行權限
# chkconfig --add httpd      //添加httpd服務
# chkconfig --list httpd      //查看httpd服務
# chkconfig --level 35 httpd on    //把httpd服務的3 5開啟

10.給httpd.conf 創建一個軟連接 方便管理

# ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
# vim /etc/httpd.conf
Listen:192.168.100.101:80      //修改監聽IP
#Listen:80     #ipv6的需要關閉
ServerName www.benet.com:80    //修改域名

11.重啟httpd服務、關閉防火墻

# service httpd stop
# service httpd star
# service iptables stop 
# setenforce 0

12.修改首頁內容測試

echo "<h1>this is web</h1>" > /usr/local/apache/htdocs/index.html

技術分享圖片

Apache手工編譯安裝(內附軟件包)