咱们如今以源代码方式安装apache httpdapache
首先咱们下载apache httpd的tar.gz的源码安装包,在http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.25.tar.gz/下载less
解压ide
[root@station129 tmp]# tar xf httpd-2.2.25.tar.bz2 工具
编译安装以前,首先安装3个开发包ui
[root@station129httpd-2.2.25]# yum groupinstall "Desktop Platform Development" "ServerPlatform Development" “Development tools”spa
进入到安装目录下,首先阅读README文件日志
而后检查环境环境(编译器,头文件,库文件)而且设置编译的配置code
首先查看帮助文档,看都支持哪些参数orm
[root@station129 httpd-2.2.25]# ./configure --helpblog
这里咱们看几个比较经常使用的参数之后供你们编译的时候使用
--bindir=DIRuser executables [EPREFIX/bin] |
二进制文件安装位置 |
--libdir=DIRobject code libraries [EPREFIX/lib |
指定库文件安装位置 |
--includedir=DIRC header files [PREFIX/include] |
头文件安装位置 |
--mandir=DIRman documentation [DATAROOTDIR/man] man |
配置文件所在位置 |
--prefix=PREFIXinstall architecture-independent files in PREFIX |
默认安装包安装的位置 |
--sysconfdir=DIRread-only single-machine data [PREFIX/etc] |
配置文件安装位置 |
咱们来正式的安装apache httpd
为了解释清楚库文件的配置,MAN,头文件的配置,咱们将再也不次指定,待会手动修改
[root@station129httpd-2.2.25]# ./configure --prefix=/usr/local/apache --enable-so--enable-rewrite
这里咱们队httpd 启用了动态连接库和URL重写功能
configure 脚本结合 makefile.in文件生成makefile文件
automake是一种生成makefile.in的工具
autoconf是一种生成configure的文件
咱们还能够查看咱们刚才日志
[root@station129 httpd-2.2.25]# less config.log 查看配置的日志文件
接下来咱们完成编译,make工具找到makefile文件完成编译
咱们还能够查看makefile文件
[root@station129 httpd-2.2.25]# make
make 其实就是包含了编译连接等功能
编译好了就能够安装了
[root@station129 httpd-2.2.25]# make install
安装完成
咱们来查看安装目录
[root@station129 apache]# ls
binbuildcgi-binconferrorhtdocsiconsincludeliblogsmanmanualmodules
这里面默认安装的着配置文件,头文件,库文件,man 配置手册
若是一个程序找不到库文件,他会报错,咱们制定库文件的位置
[root@station129 conf]# cat /etc/ld.so.conf.d/apache.conf
/usr/local/apache/lib
查看 PATH 路径,咱们发现不包含咱们安装后可执行文件的位置,咱们添加进去
[root@station129 apache]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/binpro
在/etc/profile.d/中添加一个文件
[root@station129 profile.d]# cat /etc/profile.d/apache.sh
export PATH=/usr/local/apache/bin:$PATH
使环境变量生效:
[root@station129 profile.d]# . /etc/profile.d/apache.sh
编辑man配置的文件,添加一行
MANPATH /usr/local/apache/man
系统找到头文件,建立软链接
[root@station129 include]# ln -s/usr/local/apache/include/ /usr/include/
启动apachectl而且查看
[root@station129 profile.d]# apachectl start
[root@station129 profile.d]# hash
hits command
3 /usr/local/apache/bin/apachectl
咱们来看咱们的成果
Apachectl工做正常