手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

在Amazon EC2主机上部署LAMP环境

[日期:2013-11-30] 来源:Linux社区  作者:phenixikki [字体:大 中 小]

LAMP环境:httpd 2.4.6 + MySQL-5.6.13 + php-5.4.22
系统环境:Amazon Linux (64-bit) (类似于RHEL6.4_x86_64)

一、编译安装httpd-2.4.6
1、安装httpd所依赖的软件包
$ sudo yum groupinstall Development Libraries Development tools
$ sudo mkdir /usr/src/lamp

<1> 编译安装apr
$ cd /usr/src/lamp
$ sudo wget http://down1.chinaunix.net/distfiles/apr-1.4.6.tar.bz2
$ sudo tar xf apr-1.4.6.tar.bz2
$ cd apr-1.4.6
$ sudo ./configure --prefix=/usr/local/apr
$ sudo make
$ sudo make install

<2> 编译安装apr-util

$ cd /usr/src/lamp
$ sudo wget http://apache.spinellicreations.com//apr/apr-util-1.5.2.tar.bz2
$ sudo tar xf apr-util-1.5.2.tar.bz2
$ cd apr-util-1.5.2
$ sudo ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$ sudo make
$ sudo make install

<3> Yum安装pcre-devel
$ sudo yum -y install pcre-devel

2、编译安装httpd-2.4.6

$ cd /usr/src/lamp
$ sudo wget http://mirror.cc.columbia.edu/pub/software/apache//httpd/httpd-2.4.6.tar.bz2
$ sudo tar xf httpd-2.4.6.tar.bz2
$ cd httpd-2.4.6
$ sudo ./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=all --enable-mpms-shared=all --with-mpm=event
$ sudo make
$ sudo make install

如编译出现以下错误:

checking for OpenSSL version >= 0.9.7... FAILED
configure: WARNING: OpenSSL version is too old

则需要安装最新的openssl和openssl-devel的rpm包,如默认已安装最新的openssl仍编译出错,查看openssl-devel是否未装,安装即解决问题
$ sudo yum install openssl-devel.x86_64

3、编辑httpd的主配置文件,添加Pid文件的路径

$ sudo vim /etc/httpd/httpd.conf
PidFile  "/var/run/httpd.pid"

4、为httpd提供sysv服务脚本

1 $ sudo vim /etc/rc.d/init.d/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

为此脚本添加执行权限:
$ sudo chmod +x /etc/rc.d/init.d/httpd

添加至服务列表:

$ sudo chkconfig --add httpd

5、修改PATH环境变量

$ sudo vim /etc/profile.d/httpd.sh
export PATH=$PATH:/usr/local/apache/bin

6、启动httpd服务并测试

$ sudo service httpd start

更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2013-11/93337p2.htm

推荐阅读:

Ubuntu下搭建属于自己的wiki与论坛(图) http://www.linuxidc.com/Linux/2008-02/11085.htm

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

Ubuntu下安装LAMP及phpMyAdmin http://www.linuxidc.com/Linux/2012-09/71192.htm

Ubuntu 12.04下LAMP安装配置 http://www.linuxidc.com/Linux/2012-05/61079.htm

CentOS 5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

RedHat 5.4下Web服务器架构之源码构建LAMP环境及应用PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

linux
相关资讯       lamp  Amazon EC2 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款