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

Linux 环境下手工编译安装Apache

2018-05-24 12:19 447 查看

手工编译安装Apache

实验准备:

1.VMwore 12 环境下Red Hat 6.5版本虚拟机一台

2.相关软件包:apr、apr-util、httpd

备注:apache官网下载http://www.apache.org/ 将实验所需的软件包下载好,并解压到指定文件夹

``

一、Apache安装

1.首先解压软件包http、apr、apr-util(支持Apache上层应用跨平台,提供底层接口库)至/opt目录下

tar xzvf http-2.4.2.tar.gz -C /opt

tar xzvf apr-1.4.6.tar.gz -C /opt
(支持Apache上层应用跨平台,提供底层接口库)

tar xzvf apr-util-1.4.1.tar.gz -C /opt

2.进入软件包目录,将apr和apr-util包复制到httpd目录下

cp -R apr /opt/httpd-2.4.2/srclib/apr

cp -R apr-util /opt/httpd-2.4.2/srclib/apr-util

3.安装 gcc 、 gcc-c++ 、 make 、 pcre、pcre-devel 四个包

yum install gcc gcc-c++ make pcre pcre-devel -y

4.进入httpd目录下,配置configure

cd /opt/httpd-2.4.2

5.配置

./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi

6.编译及安装

make && make install

7.过滤掉注释行(#)并复制 httpd服务文件到/etc/init.d/

grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd

8.修改配置文件vim /etc/init.d/httpd 在文章的最下面插入下面的行

#!/bin/sh

chkconfig:2345 85 15

description:Apache is a World Wide Web server

9.给httpd文件添加执行权限

chmod +x /etc/init.d/httpd

10.添加httdp服务,设置为init3、init5 时开机自启动。

chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on

11.建立/etc/httpd.conf文件的软链接,便于后期管理

ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf

12.修改配置文件httpd.conf

vim /etc/httpd.conf
Listen:#监听IP地址,这里修改为自己的本地IP地址。

ServerName:主机名.域名

13.重启httpd服务

service httpd shop

service httpd start

14.关闭防火墙

service iptables stop

setenforce 0

最终测试

如果出现上图界面就说明Apache已经安装成功了,另外主页存放路径为 /usr/local/apache/htdocs/index.html 可以在编辑此文件修改主页上的内容
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Apache 手工 编译安装