在CentOS6.5系统下编译安装LAMP(httpd2.4+MySQL5.6+PHP

什么是LAMP
LAMP指的是Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案。

需要的源码包到Linux公社1号FTP服务器下载

------------------------------------------分割线------------------------------------------

FTP地址:ftp://ftp1.linuxidc.com

用户名:ftp1.linuxidc.com

密码:

在 2016年LinuxIDC.com\6月\在CentOS6.5系统下编译安装LAMP(httpd2.4+MySQL5.6+PHP5.4)\

下载方法见

------------------------------------------分割线------------------------------------------

开始安装httpd

#安装前准备
yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel zlib zlib-devel openssl openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses ncurses-devel bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel
 
#解压
tar zxvf apr-1.5.0.tar.gz
tar zxvf apr-util-1.5.3.tar.gz
tar zxvf httpd-2.4.7.tar.gz
 
#改名
mv apr-1.5.0 apr
mv apr-util-1.5.3 apr-util
 
#移动
mv apr apr-util httpd-2.4.7/srclib/
 
#进入httpd目录
cd httpd-2.4.7
 
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-z --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support --enable-authn-dbm=shared --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-mods-shared=all --enable-ssl --enable-cgi
 
#编译安装httpd2.4
make && make install
 
#编辑httpd.conf
vi /etc/httpd/httpd.conf
 
#找到下面这句
#ServerName :80
 
#改成
ServerName localhost:80
 
#iptables添加80端口
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80-j ACCEPT
 
#重启iptables
service iptables restart
 
####################################启动脚本开始######################################################
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: 2345 85 15
# description: The Apache HTTP Server is an efficient and extensible \
# server implementing the current HTTP standards.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd/httpd.pid
#
### BEGIN INIT INFO
# Provides: httpd
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: distcache
# Short-Description: start and stop Apache HTTP Server
# Description: The Apache HTTP Server is an extensible server
# implementing the current HTTP standards.
### END INIT INFO
 
# Source function library.
./etc/rc.d/init.d/functions
 
if[-f /etc/sysconfig/httpd ];then
./etc/sysconfig/httpd
fi
 
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
 
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
 
# 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/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
 
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start(){
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL =0]&& touch ${lockfile}
return $RETVAL
}
 
# When stopping httpd, a delay (of default 10 second) is required
# before SIGKILLing the httpd parent; this gives enough time for the
# httpd parent to SIGKILL any errant children.
stop(){
echo -n $"Stopping $prog: "
killproc -p ${pidfile}-d ${STOP_TIMEOUT} $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=6
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
# Force LSB behaviour from killproc
LSB=1 killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
if[ $RETVAL -eq 7];then
failure $"httpd shutdown"
fi
fi
echo
}
 
# See how we were called.
case"$1"in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart|try-restart)
if status -p ${pidfile} $httpd >&/dev/null;then
stop
start
fi
;;
force-reload|reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
RETVAL=2
esac
 
exit $RETVAL
#######################################启动脚本结束#####################################################
 
#把上面的启动脚本添加到/etc/init.d
vi /etc/init.d/httpd
 
#赋予执行权限
chmod 755/etc/init.d/httpd
 
#设置环境变量
vi /etc/profile
 
#在末尾添加以下内容
PATH=/usr/local/apache/bin:$PATH
export PATH
 
#让刚才的修改生效
source /etc/profile
 
#启动httpd
service httpd start
 
#开机启动
chkconfig httpd on
开始安装mysql

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/0646084f17b3f3acf9445ca19b1cda9d.html