您的位置:首页 > 运维架构 > Apache

centos源码安装apache

2017-09-03 16:16 295 查看
最近在学习利用django+apache来搭建网站,需要重新用源码安装apache服务器,特根据自己遇到的问题写下此博客。

1,首先卸载原有的apache:yum remove httpd

2,下载依赖包,包括以下:

a、apr:http://mirrors.hust.edu.cn/apache//apr/apr-1.6.2.tar.gz

b、arp-uril:http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.0.tar.gz

其他下载链接可从此网站获取:http://httpd.apache.org/download.cgi#apache24

c、pcre:http://jaist.dl.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz

d、apache:http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.27.tar.gz

其他下载链接可从此网站获取:http://httpd.apache.org/download.cgi#apache24

3,安装gcc、make、gcc-c++,必须安装gcc-c++,不然编译不了pcre:

yum
-y install gcc

yum
-y install make

yum
-y install gcc-c++

4,安装apr:

tar
-zxvf apr-1.6.2.tar.gz

cd
apr-1.6.2

./configure
--prefix=/usr/loca/apr/

make
&& make install

5,安装apr-util:

tar
-zxvf apr-util-1.6.0.tar.gz

cd
apr-util-1.6.0

./configure
--prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr-util/

注:这里必须加上参数--with-apr,不然会报错,所以安装顺序也必须是apr在前面。

make && make
install

6,安装pcre:

tar-zxvf pcre-8.41.tar.gz

cd pcre-8.41

./configure --prefix=/usr/local/pcre/

make && make install

7,安装apache:

注:安装apache时必须完成以上步骤

tar -zxvf httpd-2.4.27.tar.gz

cd httpd-2.4.27

./configure --prefix=/usr/local/apache –with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre/

make
&& make install

至此已经完成安装apache服务器。

还需:

8,将http添加为系统服务:

cp apachectl /etc/init.d/httpd

vi /etc/init.d/httpd

编辑httpd,在第二行中加入信息:

# chkconfig: 345 85 15

# description: Activates/Deactivates Apache Web Server

这两句必须添加,不然启动httpd时提示“httpd服务不支持”;第一行3个数字参数意义分别为:哪些linux级别需要启动httpd(3,4,5);

启动序号(85);关闭序号(15)

9,添加启动信息:

chkconfig --add httpd

查看是否添加成功:

chkconfig --list

自此可通过service httpd start | stop | restart来起停服务。

参考自:http://www.linuxidc.com/Linux/2016-03/128956.htm
http://blog.csdn.net/wplblog/article/details/52172128
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  apache 源码 安装 centos