CentOS 下编译安装Apache

本文详细介绍了在CentOS环境下编译安装Apache的过程,包括安装所需的依赖软件包apr、apr-util及pcre等,同时提供了配置Apache服务的具体步骤。

CentOS 下编译安装Apache

卸载原有的apache

首先从 http://httpd.apache.or 下载apache源码包httpd-2.4.4.tar.gz
然后从 http://apr.apache.org 下载apr-1.4.6.tar.gz和apr-util-1.5.1.tar.gz
然后从 http://sourceforge.net/ 下载pcre-8.32.tar.gz和pcre-devel-8.32.tar.gz

先装gcc和make
yum -y install gcc
yum -y install make
yum -y install gcc-c++ 没有这个gcc-c++一会编译不prce
切到下载好的源码包目录,本人是~/Download


安装apr:
tar -zvxf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install


安装apr-util
tar -zvxf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install


安装pcre
tar -zvxf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make && make install

 

安装pcre-devel
如果已经安装好了pcre 一定要安装
tar –zxvf pcre-devel-8.32.tar.gz
cd pcre-devel-8.32
./configure
make && make install


安装apache 一定要先装上面那三个不然编译不了
tar -zvxf httpd-2.4.4.tar.gz
cd httpd-2.4.4
./configure --prefix=/usr/local/apache –with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install


配置/usr/local/apache/conf下的http.conf文件(先备份)。

1、服务器
#ServerName www.example.com:80 前的#号删除。

2、目录访问权限
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all #修改为此样
</Directory>

3、默认字符集
AddDefaultCharset utf-8 #指定默认字符集


4、启动httpd
cd bin/
./apachectl start | restart | stop


将httpd添加为系统服务
cp apachectl /etc/init.d/httpd
/etc/init.d/


编辑httpd,在第二行加入如下信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
以上两句必须添加,否则会提示“httpd服务不支持”;第一行3个数字参数意义分别为:哪些Linux级别需要启动httpd(3,4,5);启动序号(85);关闭序号(15)。


添加启动信息(Ubuntu与CentOS有区别)
chkconfig –add httpd

查看是否添加成功
chkconfig --list


服务器控制
service httpd start | restart | stop

转载于:https://www.cnblogs.com/heyunxu/p/5246203.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值