linux系统下源码安装Apache2.4
linux系统下源码安装Apache2.4
下载Apache及相关依赖包(百度云盘:http::/pan.baidu.com/s/1bnL31c7)
Apache2.4版本开始不自带apr库,所以需要下载相应的库文件
1.apr(Apache依赖包) http://irrors.hust.edu.cn/apache/apr
2.apr-util(Apache依赖包) http://irrors.hust.edu.cn/apache/apr
3.pcre(Apache依赖包) http://sourceforge.net/projects/pcre/files/pcre/
4.Apache http://archive.apache.org/dist/httpd/
安装apr,apr-util以及pcre依赖包
开始安装依赖包,注意:需要将解压包放到apache软件解压后的srclib目录下面也就是这里的/soft/httpd-2.4.16/srclib/
解压Apache及相关依赖包
#tar -zxvf httpd-2.4.16.tar.gz
#tar -zxvf apr-1.5.2.tar.gz
#tar -zxvf apr-util-1.5.4.tar.g
#tar -zxvf pcre-8.37.tar.gz
将相关依赖包放入/soft/httpd-2.4.16/srclib/中
#mv apr-1.5.2 /httpd-2.4.16/srclib/apr
#mv apr-util /httpd-2.4.16/srclib/apr-util
安装apr
# cd /soft/httpd-2.4.16/srclib/
# cd apr 在目录apr下进入configure配置文件将$RM "cfgfile"这一行用#注销
# ./configure --prefix=/usr/local/apr
# make && make install
安装apr-util
# cd apr-util
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
# make && make install
安装pcre
# tar -zxvf pcre-8.37.tar.gz
# mv pcre-8.37 pcre
# ./configure --prefix=/usr/local/pcre
# make && make install
安装Apache
# cd httpd-2.4.16
# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-z=/usr/local/zlib/ --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
#make && make install
Apache安装详细说明
# ./configure \ 执行当前目录下软件自带的配置命令
> --prefix=/usr/local/apache2 \ 指定Apache软件安装的位置
> --sysconfdir=/etc/httpd \ 指定Apache服务器配置文件存放位置
> --with-z=/usr/local/zlib/ \ 指定zlib库文件的位置
> --enable-so \ 以动态共享对象(DSO)编译
> --enable-deflate=shared \ 缩小传输编码的支持
> --enable-expires=shared \ 期满头控制
> --enable-rewrite=shared \ 基于规则的URL操控
> --enable-static-support \ 建立一个静态链接版本的支持
>--with-apr=/usr/local/apr \ 加入apr依赖包安装路径
>--with-apr-util=/usr/local/apr-util\ 加入apr-util依赖包安装路径
>--with-pcre=/usr/local/pcre 加入pcre依赖包安装路径
启动apache服务
进入/etc/httpd/httpd.conf配置文件,在任意行插入一行内容
ServerName localhost:80
# /usr/local/apache2/bin/apachectl start
httpd (pid 55493) already running
注册为服务
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
# service httpd start
httpd (pid 45005) already running
查看Apache服务端口情况
# netstat -na |grep 80
tcp 0 0 :::80 :::* LISTEN
加入到chkconfig
进入/etc/init.d/httpd,在任意行插入加入两行内容
# chkconfig: 345 61 61
# description:Apache httpd
# chkconfig --add httpd
# chkconfig httpd on
关闭iptables
# iptables -F 清空iptables防火墙策略
# service iptables stop 关闭防火墙
iptables: Setting chains to policy ACCEPT: filter
iptables: Flushing firewall rules:
iptables: Unloading modules:
# chkconfig iptables off 重启后防火墙依旧处于关闭状态
关闭selinux
两种方法
1.使用命令setenforce 0 系统重启即失效(不需要重启)
2.编辑配置文件/etc/sysconfig/selinux 将SELINUX=enforcing改为disabled状态( 须重启生效)
# setenforce 0 临时将selinux改为Permission状态,重启系统后失效
# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled 将selinux改为disabled状态,需要重启系统才能生效
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
测试Apache服务
最后打开网页,输入网址http://ip即可查看网页内容
网页显示It works!就说明apache安装成功了
那么至此Apache的源码安装到此就结束了!
页:
[1]