CentOS6.x编译安装LAMP(2):编译安装 Apache2.2.22教程
#切换到源码目录
代码如下 | |
cd /usr/local/src/httpd-2.2.22 #生成configure ./configure --prefix=/usr/local/apache --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-ssl=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support --with-mpm=prefork |
#编译
代码如下 | |
make && make install |
编译参数解释:
--prefix=/usr/local/apache :指定安装目录
--with-included-apr : 在编译时强制使用当前源代码中绑定的APR版本
--enable-so : 允许运行时加载DSO模块(注意:so模块需静态编译)
--enable-deflate=shared : 将deflate模块编译为DSO
--enable-expires=shared : 将expires模块编译为DSO
--enable-ssl=shared : 将ssl模块编译为DSO
--enable-headers=shared : 将headers模块编译为DSO
--enable-rewrite=shared : 将rewrite模块编译为DSO
--enable-static-support : 使用静态连接(默认为动态连接)编译所有二进制支持程序
--with-mpm=prefork : 使用prefork形式的mpm
更详细的编译参数解释:http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html
代码如下 | |
cp ./build/rpm/httpd.init /etc/init.d/httpd #使用init脚本管理httpd mv /etc/httpd /etc/httpd_old #移走旧的httpd文件夹 ln -sf /usr/local/apache/bin/httpd /usr/sbin/httpd #设置软链接以适应init脚本 rm -rf /var/log/httpd/ groupadd apache #添加Apache用户组及用户 |
配置防火墙,开启80端口
代码如下 | |
vim /etc/sysconfig/iptables |
#添加如下规则到22端口这条规则的下面即可
代码如下 | |
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT |
#重启防火墙
代码如下 | |
/etc/init.d/iptables restart # 或 service iptables restart |
启动Apache
代码如下 | |
/etc/init.d/httpd start # 或 service httpd restart |