#检查是否安装
[root@A-host ~]# rpm -qa httpd
[root@A-host ~]# rpm -e --nodeps httpd* 删除
#环境准备:
yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs
yum install apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs -y
yum install gcc-c++
[root@A-host httpd-2.2.27]# tar -xf httpd-2.2.27.tar.gz
[root@A-host httpd-2.2.27]# cd ttpd-2.2.27
./configure --prefix=/application/apache2.2.27 \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util
make && make install
#注释
./configure --prefix=/application/apache2.2.27 \\安装目录
--enable-deflate \\数据压缩
--enable-expires \\缓存过期
--enable-headers \\http头
--enable-modules=most \\常用模块
--enable-so \\ so
--with-mpm=worker \\ 运行模式 (进程模式/线程模式)
--enable-rewrite \\伪静态
httpd-2.2.27.rar
编译apache时出错:
#./configure --prefix……检查编辑环境时出现:
checking for APR... no
configure: error: APR not found . Please read the documentation
解决办法:
1.下载所需软件包:
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.zip
具体步骤如下:
a:解决apr not found问题>>>>>>
[root@xt test]# tar -zxf apr-1.4.5.tar.gz
[root@xt test]# cd apr-1.4.5
[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr
[root@xt apr-1.4.5]# make && make install
b:解决APR-util not found问题>>>>
[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz
[root@xt test]# cd apr-util-1.3.12
[root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
[root@xt apr-util-1.3.12]# make && make install
c:解决pcre问题>>>>>>>>>
[root@xt test]#unzip -o pcre-8.42.zip
[root@xt test]#cd pcre-8.42
[root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre
[root@xt pcre-8.10]#make && make install
4.最后编译Apache时加上:
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre
成功编译完成~
#做链接
ln -s /application/apache2.2.27/ /application/apache
[root@A-host tools]# ll /application/apache/
总用量 56
lrwxrwxrwx 1 root root 26 8月 9 05:46 apache2.2.27 -> /application/apache2.2.27/
drwxr-xr-x 2 root root 4096 8月 9 05:37 bin
drwxr-xr-x 2 root root 4096 8月 9 05:37 build
drwxr-xr-x 2 root root 4096 8月 9 05:37 cgi-bin
drwxr-xr-x 4 root root 4096 8月 9 05:37 conf
drwxr-xr-x 3 root root 4096 8月 9 05:37 error
drwxr-xr-x 2 root root 4096 3月 14 2014 htdocs
drwxr-xr-x 3 root root 4096 8月 9 05:37 icons
drwxr-xr-x 2 root root 4096 8月 9 05:37 include
drwxr-xr-x 2 root root 4096 8月 9 05:37 logs
drwxr-xr-x 4 root root 4096 8月 9 05:37 man
drwxr-xr-x 14 root root 12288 3月 14 2014 manual
drwxr-xr-x 2 root root 4096 8月 9 05:37 modules
修改配置文件httpd.conf
#ServerName www.example.com:80
ServerName 127.0.0.1:80
#检查语法
/application/apache/bin/apachectl -t
#启动服务
[root@A-host tools]# /application/apache/bin/apachectl start
或
/application/apache2.2.27/bin/httpd -k start
#平滑重启
[root@A-host tools]# /application/apache/bin/apachectl graceful
#查看已编译模块
[root@A-host httpd-2.2.27]# /application/apache/bin/apachectl -l
#查看动静模块信息
/application/apache/bin/apachectl -M
[root@A-host apache]# ll bin/
总用量 3692
-rwxr-xr-x 1 root root 75821 8月 9 06:21 ab //压力测试工具,同类软件有,webbench,siege,JMetcer,loadrunner
-rwxr-xr-x 1 root root 3449 8月 9 06:20 apachectl //apache启动命令,是一个脚本
-rwxr-xr-x 1 root root 22660 8月 9 06:20 apxs //apxs是个维护为apache http 服务器编译和安装扩展模块的工具
-rwxr-xr-x 1 root root 12269 8月 9 06:21 checkgid
-rwxr-xr-x 1 root root 45312 8月 9 06:21 htcacheclean //清理磁盘缓冲区命令
-rwxr-xr-x 1 root root 31665 8月 9 06:21 htpasswd //建立和更新基本认证文件
-rwxr-xr-x 1 root root 3425283 8月 9 06:21 httpd //apachectl执行时调用的文件
-rwxr-xr-x 1 root root 24932 8月 9 06:21 rotatelogs //apache自带的日志轮询命令,cronolog也可以替代
#排除注释看配置文件
[root@A-host apache]# grep -Ev "#|^$" conf/httpd.conf>conf/httpd.conf.bak
#辅助配置文件
[root@A-host extra]# ll
总用量 56
-rw-r--r-- 1 root root 2859 8月 9 06:21 httpd-autoindex.conf
-rw-r--r-- 1 root root 1753 8月 9 06:21 httpd-dav.conf
-rw-r--r-- 1 root root 2344 8月 9 06:21 httpd-default.conf
-rw-r--r-- 1 root root 1103 8月 9 06:21 httpd-info.conf
-rw-r--r-- 1 root root 5078 8月 9 06:21 httpd-languages.conf
-rw-r--r-- 1 root root 949 8月 9 06:21 httpd-manual.conf
-rw-r--r-- 1 root root 3789 8月 9 06:21 httpd-mpm.conf
-rw-r--r-- 1 root root 2207 8月 9 06:21 httpd-multilang-errordoc.conf
-rw-r--r-- 1 root root 11530 8月 9 06:21 httpd-ssl.conf
-rw-r--r-- 1 root root 817 8月 9 06:21 httpd-userdir.conf
-rw-r--r-- 1 root root 1507 8月 9 06:21 httpd-vhosts.conf
停留在世界边缘,与之惜别