hdfdtr 发表于 2015-8-7 09:04:57

【Apache学习】编译安装httpd2.4 含傻瓜版自动安装脚本

学习编译安装httpd2.4,考虑到要和httpd2.2共存,所以安装httpd2.4时需要指定安装目录,考虑包之间的依赖关系。


1
2
3
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)




目录结构如下

1
2
3
4
5
6
7
8
9
10
# pwd
/root/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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
DATE1=`date +%s%N|cut -c1-13`
yum install -y gcc

cd /root/soft
tar jxfapr-1.5.0.tar.bz2
tar jxfapr-util-1.5.3.tar.bz2
tar jxfhttpd-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!

1
2
3
4
5
6
# ls /usr/local/apr
binbuild-1includelib
# ls /usr/local/apr-util/
binincludelib
# ls /usr/local/httpd24/
binbuildcgi-binerrorhtdocsiconsincludelogsmanmanualmodules




启动httpd2.4

1
2
3
4
5
6
将httpd2.2关闭
# service httpd status
httpd (pid30807) is running...
# service httpd stop
Stopping httpd:
                                                         




进入httpd2.4的安装目录,启动进程,查看80端口是否启动了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# cd /usr/local/httpd24/bin/
# ls
ab         checkgid   envvars-std   htdbm   httpd       rotatelogs
apachectldbmmanagefcgistarter   htdigesthttxt2dbm
apxs       envvars    htcachecleanhtpasswdlogresolve
# ./apachectl start
#

LISTEN   0      128                                                               
# ls
abapachectlapxscheckgiddbmmanageenvvarsenvvars-stdfcgistarterhtcachecleanhtdbmhtdigesthtpasswdhttpdhttxt2dbmlogresolverotatelogs
# ./apachectl start
# 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))
#





Done!




页: [1]
查看完整版本: 【Apache学习】编译安装httpd2.4 含傻瓜版自动安装脚本