【Apache學習】編譯安裝httpd2.4 含傻瓜版自動安裝腳本

學習編譯安裝httpd2.4,考慮到要和httpd2.2共存,所以安裝httpd2.4時需要指定安裝目錄,考慮包之間的依賴關係。


apr-1.5.0.tar.bz2
apr-util-1.5.3.tar.bz2(需要apr-1.5.0)
httpd-2.4.9.tar.bz2 (需要pcre-devel、openssl-devel)

目錄結構如下

[root@adelababy soft]# pwd
/root/soft
[root@adelababy soft]# tree
.
├── apr-1.5.0.tar.bz2
├── apr-util-1.5.3.tar.bz2
├── httpd-2.4.9.tar.bz2
└── httpd24_install.sh

0 directories, 4 files

httpd24_install.sh

#!/bin/bash
DATE1=`date +%s%N|cut -c1-13`
yum install -y gcc

cd /root/soft
tar jxf  apr-1.5.0.tar.bz2
tar jxf  apr-util-1.5.3.tar.bz2
tar jxf  httpd-2.4.9.tar.bz2
cd apr-1.5.0
./configure --prefix=/usr/local/apr
make && make install
cd ..

cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
cd ..

yum install -y pcre-devel
yum install -y openssl-devel

cd httpd-2.4.9
## --sysconfdir=/etc/httpd24  指定配置文件路徑
## --enable-so  啓動模塊動態裝卸載
## --enable-ssl 編譯ssl模塊 需要預先安裝openssl-devel
## --enable-cgi 支持cgi機制(能夠讓靜態web服務器能夠解析動態請求的一個協議)
## --enable-rewrite  支持url重寫
## --with-zlib  支持數據包壓縮
## --with-pcre  支持正則表達式 需要預先安裝pcre-devel
## --with-apr=/usr/local/apr  指明依賴的apr所在目錄
## --with-apr-util=/usr/local/apr-util/  指明依賴的apr-util所在的目錄
## --enable-modules=most      啓用的模塊
## --enable-mpms-shared=all   以共享方式編譯的模塊
## --with-mpm=prefork         指明httpd的工作方式爲prefork
./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install

DATE2=`date +%s%N|cut -c1-13`
echo "Running time:: $((${DATE2}-${DATE1}))"

echo "Done!"

Running time:: 209274
Done!

[root@adelababy soft]# ls /usr/local/apr
bin  build-1  include  lib
[root@adelababy soft]# ls /usr/local/apr-util/
bin  include  lib
[root@adelababy soft]# ls /usr/local/httpd24/
bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

啓動httpd2.4

將httpd2.2關閉
[root@adelababy bin]# service httpd status
httpd (pid  30807) is running...
[root@adelababy bin]# service httpd stop
Stopping httpd:
                                                           [  OK  ]

進入httpd2.4的安裝目錄,啓動進程,查看80端口是否啓動了。

[root@adelababy bin]# cd /usr/local/httpd24/bin/
[root@adelababy bin]# ls
ab         checkgid   envvars-std   htdbm     httpd       rotatelogs
apachectl  dbmmanage  fcgistarter   htdigest  httxt2dbm
apxs       envvars    htcacheclean  htpasswd  logresolve
[root@adelababy bin]# ./apachectl start
[root@adelababy bin]#

LISTEN     0      128                                                               
[root@adelababy bin]# ls
ab  apachectl  apxs  checkgid  dbmmanage  envvars  envvars-std  fcgistarter  htcacheclean  htdbm  htdigest  htpasswd  httpd  httxt2dbm  logresolve  rotatelogs
[root@adelababy bin]# ./apachectl start
[root@adelababy bin]# ss -ntlp
State      Recv-Q Send-Q                                                    Local Address:Port                                                      Peer Address:Port
LISTEN     0      128                                                                  :::22                                                                  :::*      users:(("sshd",1276,4))
LISTEN     0      128                                                                   *:22                                                                   *:*      users:(("sshd",1276,3))
LISTEN     0      128                                                           127.0.0.1:631                                                                  *:*      users:(("cupsd",1117,7))
LISTEN     0      128                                                                 ::1:631                                                                 :::*      users:(("cupsd",1117,6))
LISTEN     0      100                                                                 ::1:25                                                                  :::*      users:(("master",1384,13))
LISTEN     0      100                                                           127.0.0.1:25                                                                   *:*      users:(("master",1384,12))
LISTEN     0      128                                                                  :::47422                                                               :::*      users:(("rpc.statd",1041,11))
LISTEN     0      128                                                                   *:52751                                                                *:*      users:(("rpc.statd",1041,9))
LISTEN     0      128                                                                  :::111                                                                 :::*      users:(("rpcbind",1021,11))
LISTEN     0      128                                                                   *:111                                                                  *:*      users:(("rpcbind",1021,8))
LISTEN     0      128                                                                  :::80                                                                  :::*      users:(("httpd",61535,4),("httpd",61536,4),("httpd",61537,4),("httpd",61538,4),("httpd",61539,4),("httpd",61540,4))
[root@adelababy bin]#


Done!



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章