安装C编译器,yum install gcc.x86_64,make工具yum install make.x86_64
1、下载wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.10.tar.gz
2、下载编译安装apr
wget http://apache.fayea.com/apache-mirror//apr/apr-1.5.1.tar.gz
./configure
3、下载编译安装apr-util with apr
wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.3.tar.gz
./configure --prefix=/software/aprutil153 --with-apr=/software/apr151/
4、安装所需组件
yum install pcre-devel.i686 perl-devel.i686 (若64位则选x86_64)
5、编译安装./configure --prefix=/software/httpd2.4 --with-apr=/software/apr151/ --with-apr-util=/software/aprutil153/ --enable-so --enable-dav --enable-mods-shared=all --with-mpm=worker
6、服务安装
cp /usr/local/apache-2.4.4/bin/apachectl /etc/init.d/apache2
vi /etc/init.d/apache2
#!/bin/sh后面添加
# chkconfig: 2345 85 15
# description: Apache2
chkconfig --add apache2
7、开端口
防火墙规则
vi /etc/sysconfig/iptables
编辑配置,在
-A INPUT -j REJECT --reject-with icmp-host-prohibited
之前加入
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
service iptables restart
常用命令:
1、列出内嵌编译的模块
apachectrl -l
2、列出已加载的模块
apachectrl -t -D DUMP_MODULES
3、启动、停止
apachectrl -k start
apachectrl -k stop
4、等待线程执行完,优雅停止
apachectrl -k graceful-stop
优雅重启
apachectrl -k graceful
5、增加php支持
先下载php源码,yum install libxml2-devel.i686
编译php,得到dso模块,加载进apache
./configure --prefix=/usr/local/php5.5.0 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysql-sock=/usr/local/mysql/data/mysql.sock --with-config-file-path=/usr/local/php5.5.0/lib
在apache conf配置文件中增加支持
#php handle
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>