LAMP的编译安装解析

LAMP是一般是指一组用来运行动态网站或者服务器的相关软件,  它们共同组成了一个强大的Web应用程序平台,由于是开源软件,开发成本较低,并且随着开源软件的不断发展,它们之间也拥有了越来越高的兼容度,使得其越来越受到人们的关注。在此我们就介绍一下LAMP的编译安装及配置,我们在此用的是linux,apache,MySQL和php,好了,进入正题。

实现LAMP的编译安装,我们在此所用的软件版本分别为 httpd 2.4.1  mysql-5.5.19 和php-5.3.10

首先是编译安装httpd 2.4.1

1 准备工作:

安装httpd-2.4.1需要依赖几个软件包.(在此推荐2个软件包的下载网 站rpm.pbone.net和  rpmfind.net 以下我们用到的所有软件包基本都可在其中下载到)

apr-1.4.6-1.i386.rpm

apr-devel-1.4.6-1.i386.rpm

apr-util-1.4.1-1.i386.rpm

apr-util-devel-1.4.1-1.i386.rpm

获取以上软件包后直接升级安装

#rpm –Uvh apr-1.4.6-1.i386.rpm apr-devel-1.4.6-1.i386.rpm

#rpm –Uvh apr-util-1.4.1-1.i386.rpm apr-util-devel-1.4.1-1.i386.rpm

httpd-2.4.1编译过程也需要pcre-devel软件包,需要事先安装。此软件包系统光盘自带

如果配置好了yum源可直接yum安装 如果没有则找到直接安装

#yum install pcre-devel –y

2、编译安装httpd-2.4.1

下载httpd-2.4.1到本地,可去互联网下载此源码包.命令如下:

# tar xf httpd-2.4.1.tar.bz2

# cd httpd-2.4.1

# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl

--enable-cgi --enable-rewrite --with-zlib

# make

# make install

3、设置httpd的Pid文件的路径 方法如下:

# vim /etc/httpd/httpd.conf  添加如下一行:

PidFile  "/var/run/httpd.pid"

4、为了更好的使用httpd服务 在此我们提供一个SysV服务脚本/etc/rc.d/init.d/httpd

#vim /etc/rc.d/init.d/httpd 添加内容如下:(你也可事先在别的虚拟机上安装一个rpm的httpd 然后拷贝其httpd文件 再按照如下稍做修改即可 )

#!/bin/bash

# httpd        Startup script for the Apache 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

# 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-/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 to configuration syntax error"

failure $"not reloading $httpd due to configuration syntax error"

else

killproc -p ${pidfile} $httpd -HUP

RETVAL=$?

fi

echo

}

# See how we 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/httpd   为此脚本赋予执行权限

# chkconfig --add httpd  将此服务加入服务列表

至此httpd编译安装结束 下面就可启动服务进行测试了

#service httpd start 启动服务

#netstat –tnlp 查看下有无80端口的服务

到此apache安装完毕

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

转载注明出处:http://www.heiqu.com/49628b01f59e03539c508e54f4a4d32a.html