一、所需软件下载
测试机环境为:
Httpd2.4 下载:
Apr 下载:
Apr-util 下载:
Mariadb 10.1.21 下载:https://downloads.mariadb.org/ 官网下载目前不知道什么原因下载不了,需要通过特殊渠道(你懂得)来获取最新的软件。
php5.6.30 下载:
目前最新版已到7.1.2还是保守一点选择了5.6的版本。编译php时会依赖到其他的包,所以提前通过yum 安装
1 yum install libxml2-devel bzip2-devellibmcrypt -y
Xcache php加速工具 下载:
编译xcache 需要依赖的包有m4和autoconf两个包
1 yum install m4 autoconf -y
phpmyadmin 下载:
https://files.phpmyadmin.net/phpMyAdmin/4.6.6/phpMyAdmin-4.6.6-all-languages.zip
二、httpd安装
CentOS 6.7中安装的apr版本较低,编译httpd2.4所需较新的版本,而直接通过yum升级系统现有版本apr包时可能会将其他依赖此程序包的软件,因为apr的升级造成无法启动,所以保险起见自己手动编译新版本。
1、apr安装
~]# tar –jxf apr-1.5.2.tar.bz2 –C /usr/local/src
~]# tar –jxf apr-util-1.5.4.tar.bz2 –C /usr/local/src
~]# cd /usr/local/src/apr-1.5.2
~]# ./confirure –prefix=/usr/local/apr
~]# make && make install #apr安装完成
~]# cd /usr/local/src/apr-util-1.5.4
~]# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr #with-apr参数指定编译apr-util时所依赖的程序包,如不指定则编译时会查找系统默认的安装路径去查找。
~]# make && make install
很多人都会有疑问apr到底有什么作用,为什么每次编译都要用到这个包?
APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。
APR最大的作用就是socket调度。
2、httpd安装
将下载的httpd-2.4.25解压至/usr/local/src目录中
~]# tar –jxf httpd-2.4.25.tar.bz2 –C /usr/local/src
~]# cd /usr/local/src/httpd-2.4.25
~]# ./configure –prefix=/usr/local/apache –sysconfdir=/etc/apache–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
~]# make –j 4 && make install
#安装完成之后进行启动前配置,添加启动用户和组
~]# groupadd –r –g 80 apache
~]# useradd –r –g apache –u 80 apache
#为apache提供服务脚本
~]# vim /etc/rc.d/init.d/apache
#!/bin/bash
#
#httpd Startup script for theApache HTTP Server
#
#chkconfig: - 85 15
#description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
#processname: httpd
# config:/etc/httpd/conf/httpd.conf
# config:/etc/sysconfig/httpd
#pidfile: /var/run/httpd.pid
# Sourcefunction library.
./etc/rc.d/init.d/functions
if [ -f/etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Starthttpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# Thiswill prevent initlog from swallowing up a pass-phrase prompt if
# mod_sslneeds a pass-phrase from the user.
INITLOG_ARGS=""
# SetHTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# withthe thread-based "worker" MPM; BE WARNED that some modules may not
# workcorrectly with a thread-based MPM; notably PHP will refuse to start.
# Path tothe apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile}$httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile}${pidfile}
}
reload(){
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t>&/dev/null; then
RETVAL=$?
echo $"not reloading due toconfiguration syntax error"
failure $"not reloading $httpd dueto configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See howwe were called.
case"$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
~]# chmod +x /etc/rc.d/init.d/apache
~]# chkconfig –add apache
~]# service apache start #测试启动是否成功