应用系统是centos 6.x httpd 2.2 (apache2.4版本对apr版本要求在1.4以上,
[root@lanmp httpd-2.2.31]# rpm -q apr
apr-1.3.9-5.el6_2.x86_64
yum安装的是1.3.9版主,安装2.4版本需要源码包安装apr)
为了不影响实验效果,提前可以把selinux 和iptables 关闭
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# chkconfig ip6tables off
[root@localhost ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]# /etc/init.d/ip6tables stop
ip6tables: Setting chains to policy ACCEPT: filter [ OK ]
ip6tables: Flushing firewall rules: [ OK ]
ip6tables: Unloading modules: [ OK ]
[root@localhost ~]# sed -i "s/LINUX=.*/LINUX=disabled/g" /etc/selinux/config
[root@localhost ~]# grep -i --color linux /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX=disabled
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
SELINUXTYPE=targeted
更改完selinux后要想生效需要重启一下服务器,reboot或者shutdown -r now
yum install gcc gcc-c++ zlib-devel pcre pcre-devel apr apr-deve
这些是支持包 为了防止报错 提前yum 一下
1,下载
#cd /usr/local/src/
#wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.gz(2.2版本)
2,解压
# tar zxvf httpd-2.2.31.tar.gz
3,配置编译参数
# cd httpd-2.2.31
# ls
ABOUT_APACHE config.layout httpd.spec LICENSE README.platforms
acinclude.m4 configure include Makefile.in README-win32.txt
Apache.dsw configure.in INSTALL Makefile.win ROADMAP
build docs InstallBin.dsp modules server
BuildAll.dsp emacs-style LAYOUT NOTICE srclib
BuildBin.dsp httpd.dep libhttpd.dep NWGNUmakefile support
buildconf httpd.dsp libhttpd.dsp os test
CHANGES httpd.mak libhttpd.mak README VERSIONING
#./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
--prefix=/usr/local/apache2 指定安装位置 --with-included-apr 可以跨平台
--enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre表示以动态共享的模式安装 --with-pcre 表示正则相关的一个库
4, 编译安装
# make && make install && echo $?
5 测试
# /usr/local/apache2/bin/apachectl start (启动服务)
# /usr/local/apache2/bin/apachectl stop (停止当前服务)
# /usr/local/apache2/bin/apachectl graceful (只加载配置文件)
# ps aux | grep httpd
root 20367 0.1 0.1 4396 1696 ? Ss 18:07 0:00 /usr/local/apache2/bin/httpd -k start
daemon 20368 0.0 0.1 4396 1120 ? S 18:07 0:00 /usr/local/apache2/bin/httpd -k start
daemon 20369 0.0 0.1 4396 1120 ? S 18:07 0:00 /usr/local/apache2/bin/httpd -k start
daemon 20370 0.0 0.1 4396 1120 ? S 18:07 0:00 /usr/local/apache2/bin/httpd -k start
daemon 20371 0.0 0.1 4396 1120 ? S 18:07 0:00 /usr/local/apache2/bin/httpd -k start
daemon 20372 0.0 0.1 4396 1120 ? S 18:07 0:00 /usr/local/apache2/bin/httpd -k start
root 20381 0.0 0.0 6056 796 pts/0 S+ 18:09 0:00 grep httpd
# netstat -lnp |grep 80
tcp 0 0 :::80 :::* LISTEN 20367/httpd
到这里apache就安装完毕了 可以在IE里面输入ip地址访问一下 ,如果报错请检查一下selinux和iptables或者检测服务是否开启
# /usr/local/apache2/bin/apachectl -l (查看静态模块)
# /usr/local/apache2/bin/apachectl -M (查看动态模块)
命令是不是很长啊 我们做一些修改 编辑path文件然后自定义
[root@lanmp httpd-2.2.31]# vim /etc/profile.d/path.sh
[root@lanmp httpd-2.2.31]# cat !$
cat /etc/profile.d/path.sh
#!/bin/bash
export PATH=$PATH:/usr/local/apache2/bin
[root@lanmp httpd-2.2.31]# . /etc/profile.d/path.sh 或者 source /etc/profile.d/path.sh
# ls /usr/local/apache2/modules/ (动态配置文件)
httpd.exp mod_deflate.so mod_expires.so mod_rewrite.so
# ls /usr/local/apache2/bin/httpd (静态配置文件)
/usr/local/apache2/bin/httpd
[root@lanmp httpd-2.2.31]# apachectl start (启动服务)
[root@lanmp httpd-2.2.31]# apachectl stop (关闭服务)
[root@lanmp httpd-2.2.31]# apachectl -l (查看静态模块)
[root@lanmp httpd-2.2.31]# apachectl -M (查看动态模块)
[root@lanmp httpd-2.2.31]# apachectl -t (检测配置文件)
[root@lanmp httpd-2.2.31]# ls /usr/local/apache2/conf/httpd.conf (语法配置文件)
[root@lanmp httpd-2.2.31]# vim /usr/local/apache2/htdocs/index.html (网页内容)
这些要熟记哦