一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

CentOS6.x编译安装LAMP(2):编译安装 Apache2.2.22教程

时间:2013-08-17 编辑:简简单单 来源:一聚教程网

#切换到源码目录

 代码如下 复制代码

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
chmod 755 /etc/init.d/httpd  #增加执行权限
chkconfig --add httpd  #添加httpd到服务项
chkconfig httpd on  #设置开机启动

mv /etc/httpd  /etc/httpd_old  #移走旧的httpd文件夹
ln -s /usr/local/apache  /etc/httpd  #建立httpd的软链接,
#到时候,Apache的配置文件路径为 /etc/httpd/conf/httpd.conf,其实真实路径为 /usr/local/apache/conf/httpd.conf

ln -sf /usr/local/apache/bin/httpd  /usr/sbin/httpd  #设置软链接以适应init脚本
ln -sf /usr/local/apache/bin/apachectl  /usr/sbin/apachectl

rm -rf /var/log/httpd/
ln -s /usr/local/apache/logs  /var/log/httpd

groupadd apache  #添加Apache用户组及用户
useradd -g 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

热门栏目