標籤:pcr groupadd ice yum安裝 關閉 php 成功 direct 安裝php7
上一篇:搭建LNAMP環境(二)- 源碼安裝Nginx1.10
1.yum安裝編譯apache需要的包(如果已經安裝,可跳過此步驟)
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.建立apache使用者組和使用者
groupadd apacheuseradd -r -g apache -s /sbin/nologin -M apache
3.下載apache源碼包及依賴包apr和apr-util,將它們放到/usr/local/src/目錄下
源碼包下載頁面:http://httpd.apache.org/download.cgi
依賴包下載頁面:http://apr.apache.org/download.cgi
這裡用的是 httpd-2.4.23.tar.gz ,apr-1.5.2.tar.gz ,apr-util-1.5.4.tar.gz
apache: http://apache.fayea.com/httpd/httpd-2.4.23.tar.gz
apr: http://apache.fayea.com/apr/apr-1.5.2.tar.gz
apr-util: http://apache.fayea.com/apr/apr-util-1.5.4.tar.gz
4.進入src/目錄
cd /usr/local/src/
5.解壓apache源碼包及依賴包
tar -zxf httpd-2.4.23.tar.gztar -zxf apr-1.5.2.tar.gztar -zxf apr-util-1.5.4.tar.gz
6.編譯安裝apr
cd /usr/local/src/apr-1.5.2./configure --prefix=/usr/local/aprmake && make install
註:如果./configure時出現報錯:
error info:rm: cannot remove `libtoolT‘: No such file or directory
解決方案:
開啟configure檔案
vim configure
找到
$RM "$cfgfile"
改為
$RM -f "$cfgfile"
儲存後再次執行即可
7.編譯安裝apr-util
cd /usr/local/src/apr-util-1.5.4./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/make && make install
8.編譯安裝apache(配置參數:http://httpd.apache.org/docs/2.4/programs/configure.html)
cd /usr/local/src/httpd-2.4.23./configure --prefix=/usr/local/apache --sysconfdir=/usr/local/apache/conf --enable-so --enable-cgi --enable-deflate --enable-rewrite --enable-modules=most --enable-mpms-shared=all --enable-ssl --with-ssl --with-z --with-pcre --with-zlib --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/make && make install
9.修改apache設定檔httpd.conf
vim /usr/local/apache/conf/httpd.conf
10.修改為下面內容,儲存退出
#如果前面已經安裝了nginx,為防止連接埠衝突,這裡改為其他連接埠Listen 8088#使用者組和使用者改為apacheUser apacheGroup apache#ServerName www.example.com:80ServerName 127.0.0.1
11.修改apache目錄許可權
chown -R apache:apache /usr/local/apache
12.將apache服務指令碼加入到init.d/目錄
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
13.修改指令碼httpd
vim /etc/init.d/httpd
14.在首行 #!/bin/sh 下面加入兩行:
# chkconfig: 345 85 15# description: Activates/Deactivates Apache Web Server
第一行3個數字參數意義分別為:哪些Linux層級需要啟動httpd(3,4,5);啟動序號(85);關閉序號(15)
15.將apache加入系統服務
chkconfig --add httpd
16.修改服務的預設啟動等級
chkconfig httpd on
17.啟動apache
service httpd start
訪問URL,如:http://192.168.8.9:8088/
頁面顯示正常,則配置成功
Apache安裝完畢!
下一篇:搭建LNAMP環境(四)- 源碼安裝PHP7
搭建LNAMP環境(三)- 源碼安裝Apache2.4