编译安装LAMP平台

2024-04-08 00:23:00

上篇博客安装的LAMP平台是用rpm包安装的,那么当在某些时候我们需要用到的一些功能而rpm包在制作的过程中没有把此功能做进去,那么怎么办呢,自己下载源代码进行编译安装,编译安装可以根据自己的需求配置安装软件,在企业中大多数都是编译安装的,下面将在一台默认安装有rhel5.8的系统上编译安装httpd-2.4.2和php-5.3.14和mysql-5.1.41来搭建LAMP应用平台,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
目录
一, 编译安装httpd-2.4.1
二,给编译安装的httpd提供SysV服务启动脚本 
三, 编译安装mysql-5.1.41
四,编译安装php-5.3.14
五, 配置LAMP
六, 压力测试PHP页面的响应速度,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
准备以下软件包:
apr-1.4.6.tar.bz2 
apr-util-1.4.1.tar.bz2
httpd-2.4.1.tar.bz2
mysql-5.1.41.tar.gz
php-5.3.14.tar.bz2
以上软件包准备好了之后复制到/usr/src目录里

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
一.编译安装apache,
1.  编译安装apr, 那么apr是什么? Apache Portable Run-time Librarie (apache的可移植运行库),我们都知道apache有很多版本,比如说w32的版本,network的版本等多种操作系统平台的版本,那么这么多的版本apache官方是不是每个操作系统平台都要新开发一个版本呢?,这个对apache官方来说不是什么难事,而对于那些开发模块的人来说,我开发一个新功能到底是跑在linux版本的apache还是跑在windows版本的apache呢?那么对于开发模块的那些人是不是也要开发不同操作系统的模块,这样岂不是很苦恼的一个事情,那么有了apr以后,对于应用程序而言.它们根本就不需要考虑具体的平台,不管是Unix .Linux还是Window的,apr类似java虚拟机,让apache跑在apr上.这样一来就方便多了.

  1. rhel5.8的系统上默认安装了apr-1.2.7-11版本的,对于httpd-2.4版本apr-1.2.7在某些功能能上是不支持的,所以我们这里要编译安装比较新版本的apr
  2. 首先来安装基本开发库,需要注意的是这里装的基本开发库并不是只给apr用的,像下面编译http,等等都需要用到的
  3. #yum -y groupinstall "Development Libraries" "Development Tools"
  4. #cd /usr/src
  5. #tar xjvf apr-1.4.6.tar.bz2
  6. #cd apr-1.4.6
  7. #./buildconf
  8. #./configure --prefix=/usr/local/apr
  9. #make && make install
  10. #cd /usr/src
  11. #tar xjvf apr-util-1.4.1.tar.bz2
  12. #cd apr-util-1.4.1
  13. #./buildconf --with-apr=/usr/src/apr-1.4.6 这里需要注意的是指定的目录是apr的源码目录
  14. #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  15. #make && make install

2.编译安装apache

  1. 解决依赖关系
  2. #yum -y install pcre-devel
  3. 安装apache
  4. #cd /usr/src
  5. #tar xjvf httpd-2.4.1.tar.bz2
  6. #cd httpd-2.4.1
  7. #./configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite \ --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
  8. #make && make install

3. 将apache的命令以及头文件添加到系统搜素路径

  1. 添加apahe命令到系统搜索路径
  2. #vim /etc/profile   在文件的44行上面添加一行如下
  3. PATH=/usr/local/apache/bin:$PATH
  4. #export PATH=/usr/local/apache/bin:$PATH
  5. 添加头文件到系统搜索路径
  6. #ln -sv /usr/local/apache/include /usr/include/apache

二.给编译安装的apache提供SysV服务启动脚本,
SysV是Red Hat的系统上独有的服务启动脚本,我们都知道编译安装的服务程序,默认不支持service 来启动,停止等等,这样的话在某些时候需要重启服务,停止服务,等等不是很方便,那么下面提供了一个httpd的服务启动脚本
1.修改httpd主配置文件,添加pidfile文件路径

  1. #echo "pidfile "/var/run/httpd.pid"" >> /usr/local/apache/conf/httpd.conf

2.在其它安装有rpm包的httpd 的RHEL的系统上复制两个文件到本地,并加以修改

  1. 服务启动脚本配置文件,位于/etc/sysconfig/httpd  复制到本地相同目录下即可
  2. 服务启动脚本, 位于/etc/init.d/httpd  复制到本地相同目录下
  3. 至于怎么复制自己想办法,
  4. 下面来修改服务启动脚本
  5. #vim /etc/init.d/httpd  内容如下
  6. #!/bin/bash
  7. #
  8. # httpd        Startup script for the Apache HTTP Server
  9. #
  10. # chkconfig: - 85 15
  11. # description: Apache is a World Wide Web server.  It is used to serve \
  12. #          HTML files and CGI.
  13. # processname: httpd
  14. # config: /etc/httpd/conf/httpd.conf
  15. # config: /etc/sysconfig/httpd
  16. # pidfile: /var/run/httpd.pid
  17. # Source function library.
  18. . /etc/rc.d/init.d/functions
  19. if [ -f /etc/sysconfig/httpd ]; then
  20. . /etc/sysconfig/httpd
  21. fi
  22. # Start httpd in the C locale by default.
  23. HTTPD_LANG=${HTTPD_LANG-"C"}
  24. # This will prevent initlog from swallowing up a pass-phrase prompt if
  25. # mod_ssl needs a pass-phrase from the user.
  26. INITLOG_ARGS=""
  27. # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
  28. # with the thread-based "worker" MPM; BE WARNED that some modules may not
  29. # work correctly with a thread-based MPM; notably PHP will refuse to start.
  30. # Path to the apachectl script, server binary, and short-form for messages.
  31. apachectl=/usr/local/apache/bin/apachectl
  32. httpd=${HTTPD-/usr/local/apache/bin/httpd}
  33. prog=httpd
  34. pidfile=${PIDFILE-/var/run/httpd.pid}
  35. lockfile=${LOCKFILE-/var/lock/subsys/httpd}
  36. RETVAL=0
  37. start() {
  38. echo -n $"Starting $prog: "
  39. LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
  40. RETVAL=$?
  41. echo
  42. [ $RETVAL = 0 ] && touch ${lockfile}
  43. return $RETVAL
  44. }
  45. stop() {
  46. echo -n $"Stopping $prog: "
  47. killproc -p ${pidfile} -d 10 $httpd
  48. RETVAL=$?
  49. echo
  50. [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
  51. }
  52. reload() {
  53. echo -n $"Reloading $prog: "
  54. if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
  55. RETVAL=$?
  56. echo $"not reloading due to configuration syntax error"
  57. failure $"not reloading $httpd due to configuration syntax error"
  58. else
  59. killproc -p ${pidfile} $httpd -HUP
  60. RETVAL=$?
  61. fi
  62. echo
  63. }
  64. # See how we were called.
  65. case "$1" in
  66. start)
  67. start
  68. ;;
  69. stop)
  70. stop
  71. ;;
  72. status)
  73. status -p ${pidfile} $httpd
  74. RETVAL=$?
  75. ;;
  76. restart)
  77. stop
  78. start
  79. ;;
  80. condrestart)
  81. if [ -f ${pidfile} ] ; then
  82. stop
  83. start
  84. fi
  85. ;;
  86. reload)
  87. reload
  88. ;;
  89. graceful|help|configtest|fullstatus)
  90. $apachectl $@
  91. RETVAL=$?
  92. ;;
  93. *)
  94. echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  95. exit 1
  96. esac
  97. exit $RETVAL

3,给脚本执行权限,并添加系统服务,及下次开机自启

  1. #chmod a+x /etc/init.d/httpd
  2. #chkconfig --add httpd
  3. #chkconfig httpd on
  4. #service httpd start

上面脚本中默认有个chack13的函数,那个函数是检查一系列文件是否存在的, 我们可以不要那个函数,我已经将其删掉了,需要注意的是start函数中有调用chack13函数的,有需要将调用函数那行删掉,其他改动的地方就两个变量apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd}
   
三.编译安装mysql数据库
1 .安装mysql

  1. #cd /usr/src
  2. #tar xzvf mysql-5.1.41.tar.gz
  3. #cd mysql-5.1.41
  4. #./configure --prefix=/usr/local/mysql --sysconfdir=/usr/local/mysql/etc --with-ssl \
  5. --localstatedir=/usr/local/mysql/database --enable-assembler --with-readline \
  6. --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables \
  7. --with-embedded-server --enable-local-infile  --with-plugins=innobase
  8. #make && make install

2. 添加mysql命令,库文件,及头文件为系统搜素路径

  1. 添加mysql命令为系统搜索路径
  2. #vim /etc/porfile   在文件的44行修改如下
  3. PATH=/usr/local/apache/bin:/usr/local/mysql/bin:$PATH
  4. #export PATH=/usr/local/mysql/bin:$PATH
  5. 添加库文件为系统搜索路径
  6. #echo "/usr/local/mysql/lib/mysql" > /etc/ld.so.conf.d/mysql.conf
  7. #ldconfig
  8. 添加头文件为系统搜索路径
  9. ln -sv /usr/local/mysql/include/mysql /usr/include/mysql

3.给mysql提供配置文件及启动服务

  1. 创建mysql用户
  2. #useradd -s /sbin/nologin mysql
  3. #chown -R mysql:mysql /usr/local/mysql
  4. 复制配置文件
  5. #cp /usr/src/mysql-5.1.41/support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
  6. 复制服务启动脚本
  7. #cp /usr/src/mysql-5.1.41/support-files/mysql.server /etc/init.d/mysqld
  8. #chmod a+x /etc/init.d/mysqld
  9. 初始化数据库
  10. #/usr/local/mysql/bin/mysql_install_db --user=mysql
  11. 添加为系统服务并启动
  12. #chkconfig --add mysqld
  13. #chkconfig mysqld on
  14. #service mysqld restart
  15. 为mysql数据库管理员设置密码
  16. #mysqladmin -u root password redhat

四.编译安装php
1. 安装基本开发库,因为在很多程序开发的时候需要依赖系统上的开发库

  1. #yum -y groupinstall "X Software Development"

2.安装php

  1. #cd /usr/src
  2. #tar xjvf  php-5.3.14.tar.bz2
  3. #cd php-5.3.14
  4. #./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl \
  5. --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir \
  6. --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml \
  7. --with-apxs2=/usr/local/apache/bin/apxs  --with-config-file-path=/etc  \
  8. --with-config-file-scan-dir=/etc/php.d --with-bz2
  9. #make && make install

3.给php提供配置文件

  1. #cp /usr/src/php-5.3.14/php.ini-production /etc/php.ini

php的配置基本已经结束了,下面来让httpd支持php

五,配置LAMP
    其实也就是编辑下httpd的主配置文件让其支持php
1.编辑httpd的主配置文件让其支持php

  1. #vim /usr/local/apache/conf/httpd.conf 修改以下内容
  2. AddType application/x-httpd-php  .php  新加此行
  3. AddType application/x-httpd-php-source  .phps  新加次行
  4. DirectoryIndex  index.php  index.html   找到次行添加index.php

2.重启httpd服务

  1. #service httpd restart

六,压力测试PHP页面的响应速度,
1.  使用httpd自带压力测试命令ab来测试

  1. #ab -n 10000 -c 100 http://192.168.0.53/index.php  这里的IP是服务器的IP地址
  2. This is ApacheBench, Version 2.3 <$Revision: 1178079 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking 192.168.0.53 (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software:        Apache/2.4.1
  18. Server Hostname:        192.168.0.53
  19. Server Port:            80
  20. Document Path:          /index.php
  21. Document Length:        46500 bytes
  22. Concurrency Level:      100
  23. Time taken for tests:   10.322 seconds
  24. Complete requests:      10000
  25. Failed requests:        0
  26. Write errors:           0
  27. Total transferred:      466660000 bytes
  28. HTML transferred:       465000000 bytes
  29. Requests per second:    968.81 [#/sec] (mean)
  30. Time per request:       103.219 [ms] (mean)
  31. Time per request:       1.032 [ms] (mean, across all concurrent requests)
  32. Transfer rate:          44151.01 [Kbytes/sec] received
  33. Connection Times (ms)
  34. min  mean[+/-sd] median   max
  35. Connect:        0   15  16.9      8     101
  36. Processing:     5   88  29.6     88     270
  37. Waiting:        0   36  27.9     30     218
  38. Total:          8  103  28.7    105     278
  39. Percentage of the requests served within a certain time (ms)
  40. 50%    105
  41. 66%    114
  42. 75%    119
  43. 80%    122
  44. 90%    130
  45. 95%    145
  46. 98%    173
  47. 99%    195
  48. 100%    278 (longest request)

ok到这里基本已经配置完成了.编译安装软件的时候可以根据自己的需求,配置自己的编译参数,

本文出自 “小蚂蚁” 博客,请务必保留此出处http://ant595.blog.51cto.com/5074217/920996

转载于:https://blog.51cto.com/sopace/964835

编译安装LAMP平台相关推荐

  1. 编译安装LAMP及分离式LAMP平台构建

    前言 LAMP网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache网站服务器,MySQL数据库,Perl.PHP或者Python编程语言,所有组成产品均是开源软件,是国际上 ...

  2. 2-21-源码编译安装LAMP

      编译安装LAMP所需要及其所使用的源码版本: httpd version:httpd-2.4.16 apr version:apr-1.5.2 pcre version:pcre-8.37 apr ...

  3. Web服务 源码编译安装LAMP架构

    Web服务 源码编译安装LAMP架构 一.LAMP架构 1.LAMP架构是什么 2.各组件的主要作用 二.编译安装Apache httpd服务 1.关闭防火墙,将安装Apache所需软件包传到/opt ...

  4. 源码编译安装LAMP

    源码编译安装LAMP 前言 一.LAMP概述 (1)各组件的作用 (2)各组件安装顺序 (3)数据流向 二.编译安装apache httpd服务 (1)关闭防火墙,将安装apache的所需软件包上传到 ...

  5. 盘古开天辟地之源码编译安装LAMP

    盘古开天辟地之源码编译安装LAMP Apache简介 Apache起源 源于APatchy Server,著名的开源Web服务软件 1995年时,发布Apache服务程序的1.0版本 由Apache软 ...

  6. 源码编译安装LAMP环境

    1.请描述一次完整的http请求处理过程: 2.httpd所支持的处理模型有哪些,他们的分别使用于哪些环境. 3.源码编译安装LAMP环境(基于wordpress程序),并写出详细的安装.配置.测试过 ...

  7. (1)编译安装lamp三部曲之apache-技术流ken

    简介 采用yum安装lamp简单,快捷,在工作中也得到了普遍应用.但是如果我们需要某些特定模块功能,以及制定安装位置等,就需要用到编译安装了,接下来将编译安装lamp之apache. 系统环境及服务版 ...

  8. 一键编译安装LAMP环境

    一键编译安装LAMP环境 说明:请把所需要的软件包放在文件夹中,把文件夹重命名为packages,然后压缩成packages.zip的包,上传到linux系统上任何目录都可以,然后在上传package ...

  9. 编译安装baas平台-cello-h3c

    编译安装baas平台-cello-h3c ****************************主节点管理员端的操作============= *************************** ...

  10. linux源码编译安装lamp环境搭建,linux下源码包编译安装LAMP环境

    1.下载所需的源码包 Httpd-2.4.10  apr-1.5.1  apr-util-1.5.3  pcre-8.33(这些均可在Apache官网进行下载) Mysql-5.5.39    php ...

最新文章

  1. Windows7下配置MinGW+CodeBlocks+OpenCV2.3.1
  2. classlink error java,java – EclipseLink:对MappedSuperclass的查询失败
  3. Winhex添加文件头的方法
  4. 『 编程思维』之我见
  5. c++ long 转 short_C精品编程之——C语言的数据类型、运算符、表达式,精品课程...
  6. mysql数据库 set类型_MYSQL数据库数据类型
  7. (转)比特币基金难产 区块链基金成首发
  8. 如何将一个集合转换成json格式?
  9. linux设置挂载服务端防火墙_「rpcbind」Linux下nfs+rpcbind实现服务器之间的文件共享(mount 挂载) - seo实验室...
  10. 社区志愿者招募管理系统
  11. rxjava背压_Android RxJava :图文详解 背压策略
  12. 【接口自动化】3.写接口自动化case要注意的点
  13. Android 双卡双待识别
  14. 批量转账到支付宝ISV(API接口流程步骤)
  15. 网络文件夹目前是以其他用户名和密码进行映射的
  16. 和小伙伴们一起学Unity3D(六)碰撞与触发器
  17. 华硕B660 Prime Plus D4声卡驱动安装后无控制面板界面现象
  18. 【坑】html5中使用canvas画圆,弧度和角度傻傻分不清楚
  19. C++信徒的摩西十戒
  20. FFplay 播放器

热门文章

  1. android 保留edittext中的文字不被后面添加的文字覆盖_【Go语言绘图】图片添加文字(一)...
  2. 如何使用代码获取电脑内存_代码实战 | 如何在 Android 开发中使用协程
  3. java 小数如何转换成百分数_看似简单,在JAVA中如何将一个Object转换成Array
  4. maven库的查询和配置
  5. cwm recovery 6.0.2.3下载_造梦西游3星辰辅助下载-造梦西游3星辰修改器下载v3.7.0 免费版...
  6. linux下的终端利器----tmux
  7. include指令的局限性
  8. 一个程序员成功的六个阶段
  9. 【TDA4系列】Linux SDK安装与交叉编译测试,以及刷写SD卡
  10. mapreduce对日志数据上下行流量汇总