apache源码安装

源码安装apache步骤

1.下载源码

wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.35.tar.gz

2.解压缩到/usr/local/src下

tar -zxvf httpd-2.4.35.tar.gz -C /usr/local/src

3.用configure产生makefile文件

./configure --prefix=/usr/local/httpd/ --sysconfdir=/etc/httpd/ --with-include-apr --disable-userdir --enable-headers --with-mpm=worker --enable-modules=               most --enable-so --enable-deflate --enable-defate=shared --enable-expires-shared --enable-rewrite=shared --enable-static-support --with-apr=/usr/local/apr/ --wi               th-apr-util=/usr/local/apr-util/bin --with-ssl

由于我安装的linux是最小化安装在编译时多次报错,因为很多依赖库未安装根据报错内容操作即可;

yum install pcre-devel-7.8-6.el6.x86_64.rpm -y
yum install zlib-devel-1.2.3-29.el6.x86_64.rpm -y

4.编译、编译安装

 make && make install

5.制作启动脚本和自启动

[root@www1 ~]#cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd   #拷贝apache的启动脚本到/etc/init.d下
[root@www1 ~]#vim /etc/init.d/httpd
#!/bin/sh
# chkconfig: 345 61 61    #启动等级、启动时启动的顺序、关机时关闭的顺序
[root@www1 ~]#chkconfig --add httpd
[root@www1 ~]#chkconfig --level 2345 httpd on

6.修改环境变量

[root@www1 ~]#cat >>/etc/profile <<end
export PATH=$PATH:/usr/local/httpd/bin/
end
[root@www1 ~]#source /etc/profile

7.启动apache

[root@www1 ~]#/etc/init.d/httpd start
[root@www1 ~]#netstat -antup | grep 80  #查看端口是否启动


猜你喜欢

转载自blog.51cto.com/12107790/2287447