CentOS6.6上编译安装httpd2.4
时间:2015-06-27 15:42 来源:linux.it.net.cn 作者:IT
[root@parparxy ~]# hostname
parparxy.com
wget http://apache.dataguru.cn//apr/apr-1.5.2.tar.bz2
wget http://apache.dataguru.cn//apr/apr-util-1.5.4.tar.gz
wget http://apache.fayea.com//httpd/httpd-2.4.12.tar.bz2
# httpd 2.4所依赖的apr与apr-util需1.4以上版本,而CentOS 6.6自带的版本较低,需单独安装
[root@parparxy tmp]# rpm -qa | grep apr
apr-util-1.3.9-3.el6_0.1.x86_64
apr-1.3.9-5.el6_2.x86_64
[root@parparxy tmp]# tar xf apr-1.5.2.tar.bz2
[root@parparxy tmp]# cd apr-1.5.2
[root@parparxy apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@parparxy apr-1.5.2]# make && make install
[root@parparxy tmp]# tar xf apr-util-1.5.4.tar.gz
[root@parparxy tmp]# cd apr-util-1.5.4
[root@parparxy apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@parparxy apr-util-1.5.4]# make && make install
[root@parparxy tmp]# tar xf httpd-2.4.12.tar.bz2
[root@parparxy tmp]# cd httpd-2.4.12
[root@parparxy httpd-2.4.12]# ./configure --prefix=/usr/local/apache \
> --sysconfdir=/etc/httpd \ # 指定配置文件路径
> --enable-so \ # 支持动态加载DSO模块
> --enable-ssl \ # 开启SSL功能,支持https
> --enable-cgi \ # 启用与外部应用程序的cgi接口功能
> --enable-rewrite \ # 支持url重写
> --with-zlib \ # 支持web页面压缩传送
> --with-pcre \ # 增强型的正则表达式分析工具,nginx等程序依赖,依赖于pcre-devel开发包
> --with-apr=/usr/local/apr \ # 指定高版本apr程序路径,不指定则会自动指定系统默认版本
> --with-apr-util=/usr/local/apr-util \ # 指定apr-util路径
> --enable-mpms-shared=all \ # 支持动态装卸载所有mpm
> --with-mpm=event \ # mpm默认使用event
> --enable-modules=all # all为安装所有模块,most为安装常用模块(安装不代表启用)
[root@parparxy httpd-2.4.12]# make && make install
[root@parparxy ~]# vim /etc/httpd/httpd.conf
# DocumentRoot "/usr/local/apache/htdocs" # 注释掉DocumentRoot关闭主服务配置段
Include /etc/httpd/extra/httpd-vhosts.conf # 启用虚拟主机功能
[root@parparxy ~]# vim /etc/httpd/extra/httpd-vhosts.conf
<VirtualHost 192.168.100.11:80>
ServerAdmin webadmin@parparxy.com
DocumentRoot "/usr/local/apache/htdocs/test1/"
ServerName test1.parparxy.com
ErrorLog "logs/test1-error_log"
CustomLog "logs/test1-access_log" common
</VirtualHost>
<VirtualHost 192.168.100.11:80>
ServerAdmin webadmin@parparxy.com
DocumentRoot "/usr/local/apache/htdocs/test2/"
ServerName test2.parparxy.com
ErrorLog "logs/test2-error_log"
CustomLog "logs/test2-access_log" common
</VirtualHost>
[root@parparxy ~]# cd /usr/local/apache/htdocs/
[root@parparxy htdocs]# mkdir test1 && echo "<h1> test1 </h1>" > test1/index.html
[root@parparxy htdocs]# mkdir test2 && echo "<h1> test2 </h1>" > test2/index.html
[root@parparxy ~]# ln -sv /usr/local/apache/bin/httpd /usr/bin/
`/usr/bin/httpd' -> `/usr/local/apache/bin/httpd'
[root@parparxy ~]# httpd -t
Syntax OK
[root@parparxy ~]# /usr/local/apache/bin/apachectl start
[root@parparxy ~]# ss -anpt | grep httpd
LISTEN 0 128 :::80 :::* users:(("httpd",20052,4),("httpd",20053,4),("httpd",20054,4),("httpd",20055,4))
(责任编辑:IT)
(责任编辑:IT) |


