011-install httpd-2.4 on CentOS 6
来源:互联网 发布:node sass 自动编译 编辑:程序博客网 时间:2024/06/06 03:11
011-httpd-compiling and installing httpd-2.4 on CentOS 6
CentOS 6
安装开发工具包组
[root@localhost yum.repos.d]# yum groupinstall "Development Tools"[root@localhost yum.repos.d]# yum groupinstall "Server Platform Development"[root@localhost yum.repos.d]# yum install pcre[root@localhost yum.repos.d]# yum install pcre-devel
下载源代码
要求apr-1.4+ apr-util-1.4+ httpd-2.4+
解压apr-1.4.6.tar.bz2 apr-util-1.4.1.tar.bz2 httpd-2.4.6.tar.bz2
[root@localhost ~]# tar -xjf apr-util-1.4.1.tar.bz2 [root@localhost ~]# tar -xjf apr-1.4.6.tar.bz2 [root@localhost ~]# tar -xjf httpd-2.4.6.tar.bz2
编译安装
在编译安装的过程中,默认安装的位置当时可能不在乎,但是如果要卸载的时候,编译安装的程序将会是一个麻烦,所以在编译安装的时候,尽量使用下面的格式。不过有的程序在编译安装的时候,其安装目录也会有build文件夹,这个文件中的文件中记录着编译时的各种选项等
]# make >& LOG_make]# make install >& LOG_install
当前httpd位置
[root@localhost yum.repos.d]# which httpd/usr/sbin/httpd
将httpd及其依赖安装至/usr/local目录下
apr-1.4+
[root@localhost apr-1.4.6]# pwd/root/apr-1.4.6[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr[root@localhost apr-1.4.6]# make -j 2 && make install
apr-util-1.4+
[root@localhost apr-util-1.4.1]# pwd/root/apr-util-1.4.1[root@localhost apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr[root@localhost apr-util-1.4.1]# make -j 2 && make install
httpd-2.4+
[root@localhost httpd-2.4.6]# pwd/root/httpd-2.4.6[root@localhost httpd-2.4.6]# ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork[root@localhost httpd-2.4.6]# make -j 2 && make install
安装后配置
1、导出头文件
如果其他程序需要使用httpd程序的各种头文件怎么办呢?一种方式就是直接显示的使用gcc指定头文件位置编译,有没有更简单的方法呢?那就是在gcc默认的搜索路径/usr/include 和 /usr/local/include中添加安装程序的头文件,最简单的方式就是使用软链接了,在程序中使用#include “httpd/xxxx.h”就可以使用httpd中的头文件了。
#在/usr/include目录下创建软链接指向程序的include目录[root@localhost ~]# ls /usr/local/apache24/bin build cgi-bin error htdocs icons include logs man manual modules[root@localhost ~]# ln -sv /usr/local/apache24/include /usr/include/httpd`/usr/include/httpd' -> `/usr/local/apache24/include'
[root@localhost bin]# ps aux | grep httpd root 103002 0.0 0.2 72840 2484 ? Ss 05:00 0:00 /usr/local/apache24/bin/httpddaemon 103003 0.0 0.1 72840 1868 ? S 05:00 0:00 /usr/local/apache24/bin/httpddaemon 103004 0.0 0.1 72840 1868 ? S 05:00 0:00 /usr/local/apache24/bin/httpddaemon 103005 0.0 0.1 72840 1868 ? S 05:00 0:00 /usr/local/apache24/bin/httpddaemon 103006 0.0 0.1 72840 1868 ? S 05:00 0:00 /usr/local/apache24/bin/httpddaemon 103007 0.0 0.1 72840 1868 ? S 05:00 0:00 /usr/local/apache24/bin/httpdroot 103009 0.0 0.0 103308 856 pts/4 S+ 05:00 0:00 grep httpd
2、导出库文件
在./configure的时候,如果没有指定lib的位置,那么lib就会有一个默认位置,这个位置可能在prefix下,也可能直接配置在某个lib目录下,因此lib的位置不同。
由于linux中库文件是基于ld程序的,如果httpd在编译安装的过程中它的库安装在/lib64或者/usr/lib64中,ld程序是可以找到httpd依赖的库的,如果安装在其他目录,那么如果其他程序需要httpd的库文件,系统就不能找到它的位置,所以导出库文件的意思就是共享httpd的库文件到整个系统,这样其他程序需要使用httpd的库文件的时候系统就可以轻松找到。就需要把库添加到/etc/ld.so.cache文件中。这个添加过程最简单的方式是使用ldconfig命令。
ldconfig作用及用法:
简单的说,它的作用就是将/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用,使所有的库文件都被缓存到ld.so.cache中,如果没做,即使库文件明明就在/usr/lib下的,也是不会被使用的,可能会导致其他程序的编译报错。
编译安装的程序在安装过程中,它的各个文件分布是不同的,比如如果将apr独立安装在/usr/local/apr目录中,那么/usr/local/apr就是一个完整的程序;如果apr安装在/usr/local目录中,那么apr程序就散落在/usr/local目录的各个角落,这也就是编译安装的时候,有些程序的默认路径就在一个很大的目录下,当要卸载的时候会比较困难。
[root@localhost ld.so.conf.d]# less ../ld.so.confinclude ld.so.conf.d/*.conf#因此直接在ld.so.conf文件中添加库位置和在/etc/ld.so.conf.d/目录中添加库位置的效果是一样的#由于httpd没有库文件,所以下面以apr为例导出库文件[root@localhost ld.so.conf.d]# touch apr.conf[root@localhost ld.so.conf.d]# echo "/usr/local/apr/lib" >> apr.conf[root@localhost ld.so.conf.d]# ldconfig#查看[root@localhost ld.so.conf.d]# ldconfig -v | grep apr/usr/local/apr/lib: libapr-1.so.0 -> libapr-1.so.0.4.6 libgstdataprotocol-0.10.so.0 -> libgstdataprotocol-0.10.so.0.25.0 libaprutil-1.so.0 -> libaprutil-1.so.0.3.9 libapr-1.so.0 -> libapr-1.so.0.3.9
参考:http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
http://blog.csdn.net/luotuo44/article/details/16970841
3、 导出man手册
/etc/man.config文件是各个man手册入口文件的配置文件
# Every automatically generated MANPATH includes these fields#MANPATH /usr/manMANPATH /usr/share/manMANPATH /usr/local/manMANPATH /usr/local/share/manMANPATH /usr/X11R6/man
根据以上在/etc/man.config目录中导入/usr/local/apache24/man目录就可以了
5、其他配置
5.1环境变量配置
在/etc/profile.d目录下创建一个httpd.sh文件,然后把路径添加到这个文件中
[root@localhost bin]# touch /etc/profile.d/httpd.sh[root@localhost bin]# echo "export PATH=/usr/local/apache24/bin:$PATH" > /etc/profile.d/httpd.sh
[root@localhost bin]# source /etc/profile.d/httpd.sh [root@localhost bin]# which apachectl /usr/local/apache24/bin/apachectl[root@localhost bin]# apachectl startAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message[root@localhost bin]# !psps aux | grep httpdroot 103062 0.0 0.2 72840 2484 ? Ss 05:06 0:00 /usr/local/apache24/bin/httpd -k startdaemon 103063 0.0 0.1 72840 1872 ? S 05:06 0:00 /usr/local/apache24/bin/httpd -k startdaemon 103064 0.0 0.1 72840 1872 ? S 05:06 0:00 /usr/local/apache24/bin/httpd -k startdaemon 103065 0.0 0.1 72840 1872 ? S 05:06 0:00 /usr/local/apache24/bin/httpd -k startdaemon 103066 0.0 0.1 72840 1872 ? S 05:06 0:00 /usr/local/apache24/bin/httpd -k startdaemon 103067 0.0 0.1 72840 1872 ? S 05:06 0:00 /usr/local/apache24/bin/httpd -k startroot 103069 0.0 0.0 103308 856 pts/4 S+ 05:06 0:00 grep httpd
5.2启动服务配置
5.2.1在编译的过程中,指定了httpd24的配置文件位于/etc/httpd24目录,这样就避免了覆盖原来系统上的http程序
[root@localhost ~]# ll /usr/local/apache24/total 52drwxr-xr-x 2 root root 4096 Dec 9 04:27 bindrwxr-xr-x 2 root root 4096 Dec 9 04:28 builddrwxr-xr-x 2 root root 4096 Dec 9 04:27 cgi-bindrwxr-xr-x 3 root root 4096 Dec 9 04:27 errordrwxr-xr-x 2 root root 4096 Dec 8 18:10 htdocsdrwxr-xr-x 3 root root 4096 Dec 9 04:27 iconsdrwxr-xr-x 2 root root 4096 Dec 9 04:28 includedrwxr-xr-x 2 root root 4096 Dec 9 04:27 logsdrwxr-xr-x 4 root root 4096 Dec 9 04:28 mandrwxr-xr-x 14 root root 12288 Jul 16 2013 manualdrwxr-xr-x 2 root root 4096 Dec 9 04:27 modules
5.2.2如何启动http24?
5.2.2.1由于编译的httpd-2.4处于一个独立的目录中,因此可以直接配置环境变量后使用
systemctl start|stop或者/usr/local/apache24/bin/httpd
5.2.2.2利用httpd-2.2的服务脚本启动
服务脚本位置
[root@localhost apache24]# cd /etc/rc.d/init.d/[root@localhost init.d]# lsabrt-ccpp bluetooth halt libvirt-guests NetworkManager pppoe-server rpcgssd spice-vdagentdabrtd cpuspeed htcacheclean lvm2-lvmetad nfs psacct rpcidmapd sshdabrt-oops crond httpd lvm2-monitor nfslock quota_nld rpcsvcgssd svnserveacpid cups ip6tables mdmonitor nfs-rdma rdisc rsyslog sysstatatd dnsmasq iptables messagebus ntpd rdma sandbox udev-postauditd firstboot irqbalance netconsole ntpdate restorecond saslauthd wdaemonautofs functions kdump netfs portreserve rngd single winbindblk-availability haldaemon killall network postfix rpcbind smartd wpa_supplicant
备份服务脚本后修改
[root@localhost init.d]# cp httpd ~
修改/etc/rc.d/init.d/httpd文件内容
#原内容# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with the thread-based "worker" MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM; notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.apachectl=/usr/sbin/apachectlhttpd=${HTTPD-/usr/sbin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0STOP_TIMEOUT=${STOP_TIMEOUT-10}
#修改上面配置文件中的这些内容就可以使用httpd-2.2的服务脚本启动http-2.4程序了apachectl=/usr/local/apache24/bin/apachectlhttpd=${HTTPD-/usr/local/apache24/bin/httpd}prog=httpdpidfile=${PIDFILE-/usr/local/apache24/logs/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
将上述的httpd服务脚本改名为httpd24后添加到不同的运行级别中
[root@localhost init.d]# mv httpd httpd24[root@localhost init.d]# chkconfig --add httpd24#查看级别[root@localhost init.d]# chkconfig --list httpd24httpd24 0:off 1:off 2:off 3:off 4:off 5:off 6:off[root@localhost init.d]# service httpd24 statushttpd (pid 103062) is running...[root@localhost init.d]# service httpd24 stopStopping httpd: [ OK ][root@localhost init.d]# ps aux | grep httpdroot 103177 0.0 0.0 103308 852 pts/5 R+ 05:21 0:00 grep httpd[root@localhost init.d]# service httpd24 startStarting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message [ OK ]
httpd-2.4编译安装的自身配置
使用不同的MPM机制
httpd-2.2使用 静态编译 方式,把MPM模块编译成不同的httpd程序,如httpd,httpd.worker,httpd.event。
#CentOS 6 httpd-2.2[root@localhost ~]# /usr/sbin/httpd -M httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerNameLoaded Modules: core_module (static) mpm_prefork_module (static) http_module (static)
httpd-2.4使用 动态编译 方式,只有一个httpd程序,这个程序在运行的时候,使用shared object文件
#CentOS 7 httpd-2.4[root@husa ~]# /usr/sbin/httpd -MAH00557: httpd: apr_sockaddr_info_get() failed for husa.hustAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this messageLoaded Modules:... dav_lock_module (shared) lua_module (shared) mpm_prefork_module (shared)
在编译安装的过程中,指定了配置文件位于/etc/httpd24目录中,而配置使用不同的MPM机制的方法是
#CentOS 6 httpd-2.4编译安装[root@localhost ~]# cd /etc/httpd24/[root@localhost httpd24]# lsextra httpd.conf magic mime.types original[root@localhost ~]# vim /etc/httpd24/httpd.conf#LoadModule mpm_prefork_module modules/mod_mpm_prefork.soLoadModule mpm_worker_module modules/mod_mpm_worker.so #以上直接修改主配置文件/etc/httpd24/httpd.conf文件中的载入模块即可[root@localhost ~]# service httpd24 restart Stopping httpd: [FAILED]Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message [ OK ][root@localhost ~]# httpd -M | grep mpmAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message mpm_worker_module (shared) #使用自定义脚本重启httpd24并检查mpm机制
综上,编译安装httpd-2.4配置不同MPM直接在主配置文件httpd.conf中修改;而yum安装httpd-2.4配置不同MPM在/etc/httpd/conf.modules.d/00-mpm.conf文件中配置
其他配置见下一篇httpd-2.4 new features config
- 011-install httpd-2.4 on CentOS 6
- Centos 6.9 Install httpd-2.4.26
- Install Bochs 2.4.6 on CentOS
- install apache-httpd on linux
- Install git from source on Centos 6
- Install svn server on centos 6
- Install Rsyslog and LogAnalyzer on Centos 6
- install MySQL 5.7 On CentOS 6
- Install VPN PPTP Server on CentOS 6
- install qpidd on centos
- Install opencv on Centos
- Install Composer on CentOS
- Install NTFS on CentOS
- Install httpd and mod_ssl on linux
- Install LLVM on CentOS-5
- Install Ceph on CentOS 5.5
- CentOS install Ruby On Rails
- Install brutessh on CentOS 5.8
- 基于ThinkPHP3.2的短信接口
- VMware 与Ubuntu通过samba服务器共享文件
- Java 入门 之 system.out.println
- Android插件化基础(4),动态启动插件中的Activity
- iOS各种图标尺寸规格
- 011-install httpd-2.4 on CentOS 6
- Swift快速入门(一)第一个Swift程序
- 关于卷积的一个血腥的讲解
- 优秀且免费的照片库
- 1、初识Reactjs——HelloWorld程序
- DOM Event (javascript 各种事件整理汇总)
- 在linux中install命令
- OJ 系列之IP地址判断有效性
- 链表插入排序