1.确认已安装 gcc
Fedora21 下可用以下命令安装
yum install -y gcc gcc-c++
2. 安装apr
# ./configure --prefix=/usr/local/apr
# make
# make install
3. 安装apr-util
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install
4.安装 pcre# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/pcre
# make
# make install
5.安装apache./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
# make
# make install
安装完后的配置
1.启动apache:
/usr/local/apache2/bin/apachectl start
2.将apache加入到系统服务,用service命令来控制apache的启动和停止
- 首先以apachectl脚本为模板生成Apache服务控制脚本:
grep -v "#" /usr/local/apache2/bin/apachectl > /etc/init.d/apache
- 用vi编辑Apache服务控制脚本/etc/init.d/apache:
vi /etc/init.d/apache
- 在文件最前面插入下面的行,使其支持chkconfig命令:
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
- 保存后退出vi编辑器,执行下面的命令增加Apache服务控制脚本执行权限:
chmod +x /etc/init.d/apache
- 执行下面的命令将Apache服务加入到系统服务:
chkconfig --add apache
- 执行下面的命令检查Apache服务是否已经生效:
chkconfig --list apache
- 命令输出类似下面的结果:
apache 0:off 1:off 2:on 3:on 4:on 5:on 6:off
表明apache服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制Apache的启动和停止。
- 启动Apache服务: service apache start
- 停止Apache服务: service apache stop
- 执行下面的命令关闭开机自启动: chkconfig apache off