LAMP - 功能强大的平台
2013-04-21 20:44
274 查看
你们以前听说过LAMP吗? 我会在这里简单的描述一下其工作原理,以及实现的过程。LAMP是一种平台,也是一种架构。我们了解,在web服务器中,有一个httpd进程,但这个进程仅能解释静态内容(网页文件,图片,各种CSS样式文件等)。若有一个动态文件,例:index.php ,则httpd无法执行,因此就需要使用php解释器实现这项功能。让httpd与php交互,将动态内容调用php解释器解析为静态内容交给httpd进程。而我们大多数请求的内容会有许多数据,因此,还需要一个数据库服务器来实现数据的管理。简单说,LAMP平台即为: httpd+php+mysql,三台服务器组成的平台。
我们这里演示完全手动编译配置LAMP,编译的版本为httpd 2.4.4 + mysql-5.5.28 + php-5.4.13,可以在官方网站下载其各个软件包(使用通用二进制安装mysql)。
一、准备软件源码包
1、在编译安装http之前需要先将apr和apr-util升级,升级的两种方式:rpm包直接升级或编译安装新版本的apr,apr-util。我在这里下载编译安装新版本的源码apr-1.4.6.tar.bz2, apr-util-1.5.2.tar.bz2。
2、下载http的源码包,httpd-2.4.4.tar.bz2
3、下载mysql的源码包,mysql-5.5.28-linux2.6-i686.tar.gz
4、下载php的源码包,php-5.4.13.tar.bz2 (若需要php支持mcrypt扩展,则还需要下载安装两个rpm包:libmcrypt-2.5.7-5.el5.i386.rpm,libmcrypt-devel-2.5.7-5.el5.i386.rpm。我这里直接下载安装)
5、下载php加速器:xche的源码包,xcache-3.0.1.tar.gz
二、前提环境
1、基于Redhat5的虚拟机
2、配置好yum仓库
3、关闭selinux
# setenforce 0
4、将系统时间与硬件时间同步
# hwclock -s
5、准备好安装环境(Development Libraries)
# yum groupinstall "Development Libraries"
三、详细过程
1、编译安装apr
【先解压缩,在解压后的源码目录中安装,编译安装三步骤:./configure,make,make install】
2、编译安装apr-util
【解压缩以及编译安装三步骤】
3、编译安装httpd
【由于httpd编译过程中依赖 pcre-devel软件包,因此需先将其安装】
【解压缩,手动编译】
(# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util)
【我们先可以根据二进制启动一下服务,并打开浏览器访问。此时已能工作】
【将http进程的pid文件放到/var/run下(默认编译后在apache/logs下)】
(编辑主配置文件后,启动服务验证即可)
# vim /etc/httpd/httpd.conf
【为httpd提供服务脚本】
我这里已经提供好一个脚本,我们只需要创建脚本文件将其复制过去就行。
# chmod +x /etc/init.d/httpd --> 加权限
# chkconfig --add httpd --> 加入服务列表
4、编译安装mysql
由于使用通用二进制安装,则可直接将压缩包解压至/usr/local使用。
【准备好一个逻辑卷,并创建一个单独的目录/mydata/data,将逻辑卷挂载至/mydata即可】
【初始化mysql要使用mysql用户和mysql组,因此,我们需自己创建】
初始化mysql
【提供主配置文件以及sysv服务的脚本】
【添加环境变量,指定二进制文件的所在路径】
# vim /etc/profile.d/mysql.sh
【启动服务测试使用】
5、编译安装php-5.4.13
【安装两个rpm包】
# rpm -ivh libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7-5.el5.i386.rpm
【解压缩,编译安装】
# cd php-5.4.13
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
# make
# make install
【提供配置文件】
【重启httpd,测试php是否成功】
6、编译安装xcache,为php加速
【解压缩,编译】
【配置文件】
【重启httpd,打开web页面验证】
# service httpd restart
这样就实现了httpd,php,mysql的结合 --> LAMP平台。必须注意,要先安装mysql载安装php,因为php的编译需要mysql的安装路径。
本文出自 “对着阳光微笑着” 博客,请务必保留此出处http://dongld.blog.51cto.com/4234800/1182930
我们这里演示完全手动编译配置LAMP,编译的版本为httpd 2.4.4 + mysql-5.5.28 + php-5.4.13,可以在官方网站下载其各个软件包(使用通用二进制安装mysql)。
一、准备软件源码包
1、在编译安装http之前需要先将apr和apr-util升级,升级的两种方式:rpm包直接升级或编译安装新版本的apr,apr-util。我在这里下载编译安装新版本的源码apr-1.4.6.tar.bz2, apr-util-1.5.2.tar.bz2。
2、下载http的源码包,httpd-2.4.4.tar.bz2
3、下载mysql的源码包,mysql-5.5.28-linux2.6-i686.tar.gz
4、下载php的源码包,php-5.4.13.tar.bz2 (若需要php支持mcrypt扩展,则还需要下载安装两个rpm包:libmcrypt-2.5.7-5.el5.i386.rpm,libmcrypt-devel-2.5.7-5.el5.i386.rpm。我这里直接下载安装)
5、下载php加速器:xche的源码包,xcache-3.0.1.tar.gz
二、前提环境
1、基于Redhat5的虚拟机
2、配置好yum仓库
3、关闭selinux
# setenforce 0
4、将系统时间与硬件时间同步
# hwclock -s
5、准备好安装环境(Development Libraries)
# yum groupinstall "Development Libraries"
三、详细过程
1、编译安装apr
【先解压缩,在解压后的源码目录中安装,编译安装三步骤:./configure,make,make install】
2、编译安装apr-util
【解压缩以及编译安装三步骤】
3、编译安装httpd
【由于httpd编译过程中依赖 pcre-devel软件包,因此需先将其安装】
【解压缩,手动编译】
(# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util)
【我们先可以根据二进制启动一下服务,并打开浏览器访问。此时已能工作】
【将http进程的pid文件放到/var/run下(默认编译后在apache/logs下)】
(编辑主配置文件后,启动服务验证即可)
# vim /etc/httpd/httpd.conf
【为httpd提供服务脚本】
我这里已经提供好一个脚本,我们只需要创建脚本文件将其复制过去就行。
# vim /etc/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
# chmod +x /etc/init.d/httpd --> 加权限
# chkconfig --add httpd --> 加入服务列表
4、编译安装mysql
由于使用通用二进制安装,则可直接将压缩包解压至/usr/local使用。
【准备好一个逻辑卷,并创建一个单独的目录/mydata/data,将逻辑卷挂载至/mydata即可】
【初始化mysql要使用mysql用户和mysql组,因此,我们需自己创建】
初始化mysql
【提供主配置文件以及sysv服务的脚本】
【添加环境变量,指定二进制文件的所在路径】
# vim /etc/profile.d/mysql.sh
【启动服务测试使用】
5、编译安装php-5.4.13
【安装两个rpm包】
# rpm -ivh libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7-5.el5.i386.rpm
【解压缩,编译安装】
# cd php-5.4.13
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
# make
# make install
【提供配置文件】
【重启httpd,测试php是否成功】
6、编译安装xcache,为php加速
【解压缩,编译】
【配置文件】
【重启httpd,打开web页面验证】
# service httpd restart
这样就实现了httpd,php,mysql的结合 --> LAMP平台。必须注意,要先安装mysql载安装php,因为php的编译需要mysql的安装路径。
本文出自 “对着阳光微笑着” 博客,请务必保留此出处http://dongld.blog.51cto.com/4234800/1182930
相关文章推荐
- 由于Python本身自带的界面库功能并不强大,我们使用Python+wxPython作为界面开发平台,在公司新的项目中进行界面开发。开发过程使用Eclipse+PyDev 作为集成开发环境。产品发布时使用Py2exe进行打包。如今,在我的团队中,Pytho
- XNA Game Studio是一套有着强大功能和简单界面的游戏制作平台,游戏开发商和游戏玩家都可以使用这套工具开发针对Windows XP以及Xbox360的游戏,XNA Game Studio分为两种版本,一种是面向初学者的EXPRESS版本,还有一种是面向专业用户的专业版。用户使用EXPRESS版本开发游戏完全免费,并且可以随意在PC上发行,不过用该工具开发的游戏若是在360上网络发行,就需要交纳99美元的年费。
- IBM Platform Symphony:功能强大的高效大数据分析平台
- Microsoft Web 平台不仅仅是一组功能强大的工具、服务器和技术
- 基于CentOS构建高功能的LAMP平台
- 高效、易用、功能强大的 api 管理平台(内附彩蛋)
- 功能强大,节约85%的快速开发平台
- 亚马逊推出VR/AR开发平台Sumerian,功能强大不同于Poly
- XNA Game Studio是一套有着强大功能和简单界面的游戏制作平台,游戏开发商和游戏玩家都可以使用这套工具开发针对Windows XP以及Xbox360的游戏,XNA Game Studio分为两种版本,一种是面向初学者的EXPRESS版本,还有一种
- (五)OpenCV提供一个功能强大的UI接口,可以在MFC、Qt、WinForms、Cocoa等平台下使用
- 哥的平台功能很强大!
- 主数据管理平台应具备的六大功能
- 通用信息化开发平台 -- 通用权限管理系统改进登录日志显示功能
- Chance – 功能强大的 JavaScript 随机数生成类库
- Linux集群技术强大功能的要点解析
- VMware View把iPad从娱乐工具变成强大办公平台 推荐
- PHP中功能强大却少用的函数