我们的系统平台是在centos7.5的环境下安装httpd2.4版本的软件,2.4版本的软件有一个特征就是需要安装arp包以及arp-util包才可以。
1、首先是下载httpd2.4版本的包,以及安装开发环境,这里开发环境直接使用组安装“Development tools”即可,(注意centos6是安装“Development tools和Server Platform Development”两种开发环境)
wget http://ftp.cuhk.edu.hk/pub/packages/apache.org//httpd/httpd-2.4.37.tar.gzyum groupinstall "Development tools"
2、解压到指定目录/usr/local目录下
tar -zxf httpd-2.4.37.tar.gz -C /usr/local
3、在/usr/local目录下创建一个httpd目录,然后在刚刚解压的目录里面开始执行configure检测依赖环境
./configure --prefix=/usr/local/httpd
发现报错:
configure: configure: Configuring Apache Portable Runtime Utility library...configure: checking for APR-util... noconfigure: error: APR-util not found. Please read the documentation.configure: configure: Configuring Apache Portable Runtime library...configure: checking for APR... noconfigure: error: APR not found. Please read the documentation.
缺少apr-util包和apr包,那我们来安装即可
yum install apr apr-util apr-devel apr-util-devel
这两个包很重要,所以大家一定要记住。也有的人是下载apr源码包编译的,都是可以的。
4、继续执行configure检测环境
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd-2.4.37]#./configure --prefix=/usr/local/httpdconfig.status: creating build/config_vars.shconfig.status: creating include/ap_config_auto.hconfig.status: executing default commandsconfigure: summary of build options: Server Version: 2.4.37 Install prefix: /usr/local/httpd C compiler: gcc CFLAGS: -pthread CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE LDFLAGS: LIBS: C preprocessor: gcc -E
哈哈,终于编译成功了,继续安装
5、接下来执行make命令完成项目构建
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd-2.4.37]#make
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -pthread -o mod_rewrite.la -rpath /usr/local/httpd/modules -module -avoid-version mod_rewrite.lo make[4]: Leaving directory `/usr/local/httpd-2.4.37/modules/mappers'make[3]: Leaving directory `/usr/local/httpd-2.4.37/modules/mappers'make[2]: Leaving directory `/usr/local/httpd-2.4.37/modules'make[2]: Entering directory `/usr/local/httpd-2.4.37/support'make[2]: Leaving directory `/usr/local/httpd-2.4.37/support'make[1]: Leaving directory `/usr/local/httpd-2.4.37'
看到这里说明编译成功了。
6、执行make install 安装
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd-2.4.37]#make installInstalling man pages and online manualmkdir /usr/local/httpd/manmkdir /usr/local/httpd/man/man1mkdir /usr/local/httpd/man/man8mkdir /usr/local/httpd/manualmake[1]: Leaving directory `/usr/local/httpd-2.4.37'
安装成功。
7、看下安装的目录
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local]#cd httpd[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd]#lsbin build cgi-bin conf error htdocs icons include logs man manual modules[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd]#cd bin[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/bin]#lsab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolveapachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/bin]#
8、我们看到了安装的目录里面有我们想要的文件,但是到这里还没有完成,我们还有一些后续工作需要做。
9、设置环境变量
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/bin]#cd /etc/profile.d/[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/profile.d]#ls256term.csh colorgrep.csh colorls.csh csh.local lang.sh less.sh sh.local vim.sh which2.sh256term.sh colorgrep.sh colorls.sh lang.csh less.csh path.sh vim.csh which2.csh[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/profile.d]#vim httpd.sh[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/profile.d]#cat httpd.sh HTTPD_HOME=/usr/local/httpdPATH=$PATH:$HTTPD_HOME/bin
最后记得source一下立即生效。
10、建立库文件信息(以.so结尾的文件)
一般上我们运行程序,Linux系统会在特定的路径下为应用查找所以来的库文件:/usr/lib、/usr/lib64、/lib、/lib64这四个目录下面,但是自己编译安装的程序提供的库文件有可能不在系统搜索的路径中,因此我们需要在系统里面添加一下。注意以.conf结尾。
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/modules]#cd /etc/ld.so.conf.d/[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#lsdyninst-x86_64.conf kernel-3.10.0-862.3.2.el7.x86_64.conf mysql-x86_64.conf[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#echo /usr/local/httpd/modules > httpd-2.4.37.conf[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#cat httpd-2.4.37.conf /usr/local/httpd/modules[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#
11、然后重新执行ldconfig命令重新生成映射缓存ld.so.conf
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /etc/ld.so.conf.d]#ldconfig
12、除了我们刚刚设置的环境变量、库文件外,我们还需要设置头文件信息。我们这里复制头文件过去即可。
[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/include]#lsapache_noprobes.h ap_expr.h ap_regkey.h http_core.h mod_auth.h util_cookies.h util_script.hap_compat.h ap_hooks.h ap_release.h httpd.h mod_core.h util_ebcdic.h util_time.hap_config_auto.h ap_listen.h ap_slotmem.h http_log.h mod_request.h util_fcgi.h util_varbuf.hap_config_auto.h.in ap_mmn.h ap_socache.h http_main.h mpm_common.h util_filter.h util_xml.hap_config.h ap_mpm.h heartbeat.h http_protocol.h scoreboard.h util_ldap.hap_config_layout.h ap_provider.h http_config.h http_request.h util_cfgtree.h util_md5.hap_config_layout.h.in ap_regex.h http_connection.h http_vhost.h util_charset.h util_mutex.h[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/include]#mkdir /usr/include/httpd[root@:vg_adn_tidbCkhsTest:172.31.30.62 /usr/local/httpd/include]#cp ./* /usr/include/httpd/
其实我们就是把httpd安装目录下的include目录的所有头文件复制一份,放置在/usr/include/httpd目录下,注意,这个httpd需要提前创建好。
13、最后就是man手册了,Centos7下面的man手册配置文件是/etc/man_db.conf文件,我们修改一下即可。