CentOS 6.4安装配置LAMP环境

系统环境:CentOS 6.4

软件源码包版本:

httpd-2.4.10
php-5.4.32
MySQL-5.5.39

一、编译安装apache2.4

1、下载所需的软件源码包,使用wget命令进行下载:

apr-1.5.1:wget
apr-util-1.5.3:wget
httpd-2.4.10:wget

2、解决依赖关系

(1)使用yum安装系统所需的一些依赖库

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre pcre-devel

(注意:在这次的安装实验中,只需要yum安装openssl,openssl-devel,pcre,pcre-devel即可正常编译完成httpd,而且上面所列出的库与工具,有不少是系统已经安装过了的,这里只是进行一下更新,还有其他的一些库是为下面编译安装mysql与php作的准备)

(2) 先编译安装apr

tar jxf apr-1.5.1.tar.bz2

cd apr-1.5.1

./configure --prefix=/usr/local/apr

make && make install

(3) 再编译安装apr-util

tar jxf apr-util-1.5.3.tar.bz2

cd apr-util-1.5.3

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr  #(注意:--with-apr=/usr/local/apr是上面安装apr的路径)

make && make install

(解释:apr,全称为Apache portable Run-time libraries,叫Apache可移植运行库,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库,安装apache都需要先安装这个库的)

3、正式编译安装httpd

tar jxf httpd-2.4.10.tar.bz2

cd httpd-2.4.10

./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --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-mods-shared=most --enable-mpms-shared=all --with-mpm=event

make && make install

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

CentOS 6.5安装配置LAMP

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置

CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)

RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind

LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP

基于Ubuntu 的LAMP 优化加固

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

4、配置httpd

(1)为httpd提供sysv服务启动与关闭脚本,把以下内容复制成/etc/init.d/httpd,并且给予此文件执行权限(chmod +x /etc/rc.d/init.d/httpd),就可以直接使用service httpd <start|stop|restart|reload>的命令形式控制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

(2)把httpd服务添加为开机自启动:

chkconfig --add httpd

chkconfig httpd on

(3)修改httpd主配置文件/etc/httpd/httpd.conf,指定httpd服务的PID文件,直接在配置文件添加如下字段:

PidFile  "/var/run/httpd.pid" 


(4)启动httpd服务,并进行访问测试

service httpd start

(注:如果启动的时候出现这个警告:httpd: apr_sockaddr_info_get() failed for longren

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName,解决方法:在/etc/httpd/httpd.conf添加ServerName 127.0.0.1)

访问测试:,如果出现It Works,就证明httpd编译安装成功

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

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