LAMP 指的Linux (操作系统)、 ApacheHTTP 服务器, MySQL (数据库软件) 和PHP (有时也是指Perl 或 Python) 的第一个字母,一般用来建立的web 服务器。
  Linux+Apache+Mysql+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案。
  其中L代表的就是我们所熟知的Linux系统;A代表的是Apache,Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。同时Apache音译为阿帕奇,是北美印第安人的一个部落,叫阿帕奇族,在美国的西南部。也是一个基金会的名称、一种武装直升机等等;M代表的是MySQL(数据库软件);P代表的是PHP (有时也是指Perl 或 Python);
使用源码包安装配置LAPM服务平台步骤:
一、Apache安装:
  要想安装httpd服务首先需要安装APR,APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。

1)检查并安装yum配置环境。
 
  
  1. #cd /etc/yum.repos.d/ 
  2. #wget ftp://172.16.0.1/pub/gls/server.repo--(自己事先准备好的yum源) 
  3. #hwclock -s --同步时间,一定要保证自己的系统时间与硬件时间一致,不然会报错。 
  4. #yum grouplist---检查yum配置环境; 
  5. #yum -y groupinstall "Development Libraries"---安装yum配置环境;

2)下载编译安装APR:
 
  
  1. #lftp 172.16.0.1 
  2. #cd pub/Sources/new_lamp/ 
  3. #get apr-1.4.6.tar.bz2 apr-util-1.4.1.tar.bz2--APR-util是APR 辅助工具 
  4. #bye
  5. #tar xf apr-1.4.6.tar.bz2 
  6. #cd apr-1.4.6 
  7. #./buildconf 
  8. #./configure --prefix=/usr/local/apr-------指定apr安装路径; 
  9. #make 
  10. #make install---APR安装完成; 

3)编译安装APR-util
 
  
  1. #cd 
  2. #tar xf apr-util-1.4.1.tar.bz2 
  3. #cd apr-util-1.4.1 
  4. #./buildconf --with-apr=/root/apr-1.4.6--执行apr源码的位置; 
  5. #./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr----指定apr和apr-util的安装路径; 
  6. #make----编译; 
  7. #make install-----安装,apr-util安装完成;

4)下载编译安装httpd:
 
  
  1. #cd
  2. #lftp 172.16.0.1 
  3. #cd pub/Sources/new_lamp/ 
  4. #get httpd-2.4.2.tar.bz2 
  5. #bye
  6. #tar xf httpd-2.4.2.tar.bz2 
  7. #cd httpd-2.4.2 
  8. #rpm -q pcre-devel----查看pcre-devel包是否已安装; 
  9. #yum -y install pcre-devel----安装pcre-devel软件包; 
  10. #./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-modules-shared=most 
  11. #make---编译; 
  12. #make install----安装;--------httpd安装完成; 
  13. #vim /etc/profile--编辑bash环境变量文件;

1)编辑bash环境的配置文件,添加httpd命令路径。
 
   

  1. # No core files by default
     
  2. ulimit -S -c 0 > /dev/null 2>&1 
  3.  
  4. if [ -x /usr/bin/id ]; then 
  5.         USER="`id -un`" 
  6.         LOGNAME=$USER 
  7.         MAIL="/var/spool/mail/$USER" 
  8. fi 
  9.  
  10. HOSTNAME=`/bin/hostname` 
  11. HISTSIZE=1000 
  12.  
  13. if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then 
  14.     INPUTRC=/etc/inputrc 
  15. fi 
  16.  
  17. PATH=/usr/local/apache/bin:$PATH ------增加该项,声明httpd位置,使对所有用户均有效;
  18. export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC 

2)使用httpd -l命令查看所有模块:
 
   
  1. [root@localhost ~]# httpd -l 
  2. Compiled in modules: 
  3.   core.c 
  4.   mod_so.c 
  5.   http_core.c 
  6.   event.c ----httpd2.4版本新特性模块;
  7. [root@localhost ~]#  

3)启用httpd服务
 
   
  1. [root@localhost bin]# apachectl start 
  2. [root@localhost bin]# netstat -tnlp 
  3. Active Internet connections (only servers) 
  4. Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name    
  5. tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LISTEN      3310/./hpiod         
  6. tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      2954/portmap         
  7. tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3688/httpd           
  8. tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      3335/sshd            
  9. tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      3351/cupsd           
  10. tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3407/sendmail        
  11. tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      3620/sshd            
  12. tcp        0      0 127.0.0.1:6012              0.0.0.0:*                   LISTEN      4318/sshd            
  13. tcp        0      0 0.0.0.0:636                 0.0.0.0:*                   LISTEN      2998/rpc.statd       
  14. tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LISTEN      3315/python          

4)编辑/etc/httpd/httpd.conf(apache的配置文件),打开虚拟主机选项
  1.  DocumentRoot: The directory out of which you will serve your 
    # documents. By default, all requests are taken from this directory, but 
    # symbolic links and aliases may be used to point to other locations. 
    # 
    #DocumentRoot "/usr/local/apache/htdocs" -------把该项禁用掉;
    <Directory "/usr/local/apache/htdocs"
 
  
  1. # Virtual hosts 
  2. Include /etc/httpd/extra/httpd-vhosts.conf ----打开虚拟主机选项;

 5)编辑/etc/httpd/extra/httpd-vhosts.conf配置文件:
 
  
  1. #<VirtualHost *:80> -------把下面示例虚拟主机选项禁用掉;
  2. #    ServerAdmin webmaster@dummy-host.example.com 
  3. #    DocumentRoot "/usr/local/apache/docs/dummy-host.example.com" 
  4. #    ServerName dummy-host.example.com 
  5. #    ServerAlias www.dummy-host.example.com 
  6. #    ErrorLog "logs/dummy-host.example.com-error_log" 
  7. #    CustomLog "logs/dummy-host.example.com-access_log" common 
  8. #</VirtualHost> 
  9. # 
  10. #<VirtualHost *:80> 
  11. #    ServerAdmin webmaster@dummy-host2.example.com 
  12. #    DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com" 
  13. #    ServerName dummy-host2.example.com 
  14. #    ErrorLog "logs/dummy-host2.example.com-error_log" 
  15. #    CustomLog "logs/dummy-host2.example.com-access_log" common 
  16. #</VirtualHost> 
  17. <VirtualHost *:80> -----------------------增加一下三个虚拟主机,主页面根据自己情况而定;
  18.    ServerName www.magedu.com 
  19.    DocumentRoot /web/vhosts/www 
  20.    <Directory "/web/vhosts/www"
  21.       Options Indexes 
  22.       AllowOverride none 
  23.       Require all granted 
  24.    </Directory> 
  25. </VirtualHost> 
  26. <VirtualHost *:80> 
  27.    ServerName pma.magedu.com 
  28.    DocumentRoot /web/vhosts/pma 
  29. </VirtualHost> 

6)编辑/etc/man.config文件,将man命令永久生效:
 
  
  1. # Every automatically generated MANPATH includes these fields 
  2. # 
  3. MANPATH /usr/man 
  4. MANPATH /usr/share/man 
  5. MANPATH /usr/local/man 
  6. MANPATH /usr/local/share/man 
  7. MANPATH /usr/X11R6/man 
  8. MANPATH /usr/local/apache/man-----添加man命令路径; 
  9. # 
  10. # Uncomment if you want to include one of these by default 

7)让apache的头文件能被访问到:
 
  
  1. #ln -sv /usr/local/apache/include/ /usr/include/ 

8)开机让httpd服务能进行正常的开启、关闭、重启:
从其它主机上复制httpd开机脚本文件到这台主机上,然后对其进行修改并放到/etc/
 
  
  1. apachectl=/usr/local/apache/bin/apachectl ----改成apachectl所在路径;
  2. httpd=${HTTPD-/usr/local/apache/bin/httpd}----改成httpd所在路径; 
  3. prog=httpd 
  4. pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid} --改成httpd.pid所在路径;
  5. lockfile=${LOCKFILE-/var/lock/subsys/httpd} 
  6. RETVAL=0 
  7. STOP_TIMEOUT=${STOP_TIMEOUT-10} 
  8.   
  9. # check for 1.3 configuration ----把以下14行注释掉,因为我这里用的不是1.3版本的apache;
  10. #check13 () { 
  11. #       CONFFILE=/etc/httpd/conf/httpd.conf 
  12. #       GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|" 
  13. #       GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|" 
  14. #       GONE="${GONE}AccessConfig|ResourceConfig)" 
  15. #       if LANG=C grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then 
  16. #               echo 
  17. #               echo 1>&2 " Apache 1.3 configuration directives found" 
  18. #               echo 1>&2 " please read /usr/share/doc/httpd-2.2.3/migration.html" 
  19. #               failure "Apache 1.3 config directives test" 
  20. #               echo 
  21. #               exit 1 
  22. #       fi 
  23. #} 
  24. # 
  25. # The semantics of these two functions differ from the way apachectl does 
  26. # things -- attempting to start while running is a failure, and shutdown 
  27. # when not running is also a failure.  So we just do it the way init scripts 
  28. # are expected to behave here. 
  29. start() { 
  30.         echo -n $"Starting $prog: " 
  31. #       check13 || exit 1 ---把改行注释掉;
  32.         LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS 
  33.         RETVAL=$? 
  34.         echo 
  35.         [ $RETVAL = 0 ] && touch ${lockfile} 
  36.         return $RETVAL 
 
  
  1. #cp httpd /etc/rc.d/init.d/httpd 
  2. #chmod +x /etc/rc.d/init.d/httpd 
  3. #chkconfig --add httpd ---将httpd服务添加到列表中去;
  4. # chkconfig httpd on 开机默认启动;

二、mysql编译安装;

 
  
  1. #lftp 172.16.0.1 
  2. #cd pub/Sources/mysql-5.5/ 
  3. #get mysql-5.5.24-linux2.6-i686.tar.gz ---下载mysql源码安装包;
  4. #useradd -r mysql ---创建mysql用户,因为mysql需要普通用户mysql用户运行;
  5. #id mysql 
  6. #finger mysql 
  7. #tar xf mysql-5.5.24-linux2.6-i686.tar.gz -C /usr/local/ ---必须要解压到/usr/local目录下;
  8. #创建一个逻辑分区----为了方便存储数据,需要创建逻辑卷,这里我创建的是/dev/sda5;
  9. #pvcreate /dev/sda5 
  10. # vgcreate myvg /dev/sda5 
  11. #lvcreate -L 1G -n mydata myvg 
  12. #mke2fs -j -L MYDATA /dev/myvg/mydata 
  13. #vim /etc/fstab 
  14. #mkdir /data 
  15. #mount -a 
  16. #mkdir /data/mysql 
  17. #chown mysql:mysql /data/mysql/ 
  18. #cd /usr/local/ 
  19. #ln -sv mysql-5.5.24-linux2.6-i686 mysql 
  20. #cd mysql 
  21. #chown -R mysql:mysql . 
  22. #scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql ---初始化mysql;
  23. #cp support-files/my-large.cnf /etc/my.cnf--提供配置文件; 
  24. #vim /etc/my.cnf
  25. thread_concurrency = 4 如果是双核的就改为4; datadir= /data/mysql --指定数据目录;
  26. #cp support-files/mysql.server /etc/rc.d/init.d/mysqld ----提供服务启动脚本;
  27. #chkconfig --add mysqld 
  28. #chkconfig --list mysqld 
  29. #chown -R root . -----为了安全将当前目录的属组和属主改为root;
  30. #service mysqld start 
  31. #vim /etc/profile-------(PATH=/usr/local/mysql/bin:$PATH) 指定环境变量;
  32. #export PATH=$PATH:/usr/local/mysql/bin/ -----重新输出使其立即生效;
  33. #vim /etc/ld.so.conf.d/mysql.conf----指定mysql的库文件/usr/local/mysql/lib 
  34. #ldconfig------通知系统重新生成;  
  35. #ln -sv /usr/local/mysql/include/ /usr/include/mysql---指定mysql的头文件; 
  36. ----mysql安装编译配置完成;

三、php编译安装;
 
  
  1. #lftp 172.16.0.1 
  2. #cd pub/Sources/new_lamp/ 
  3. #get php-5.4.4.tar.bz2  ---下载php源码安装包;
  4. #bye
  5. #tar xf php-5.4.4.tar.bz2
  6. #cd php-5.4.4 
  7. #yum -y groupinstall "X Software Development" ------安装开发库;
  8. #lftp 172.16.0.1 
  9. #cd pub/Sources/nginx/ 
  10. #mget libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7-5.el5.i386.rpm 
  11. #bye
  12. #rpm -ivh libmcrypt-* 
  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  --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --编译安装php;
  14. #make----编译;
  15. #make install ---安装-----此时php已经安装完成;

1)下面整合php和apache:
  1. #cp php.ini-production /etc/php.ini 
  2. #vim /etc/httpd/httpd.conf 
  3.  
 
  
  1. # DirectoryIndex: sets the file that Apache will serve if a directory 
  2. # is requested. 
  3. #      
  4. <IfModule dir_module> 
  5.     DirectoryIndex index.php index.html ----- 添加php页面;
  6. </IfModule>
 
 
  
  1. # probably should define those extensions to indicate media types: 
  2. # 
  3. AddType application/x-compress .Z 
  4. AddType application/x-gzip .gz .tgz 
  5. AddType application/x-httpd-php  .php  ---- 添加web能够识别的php页面类型;
  6. AddType application/x-httpd-php-source  .phps  ---- 添加web能够识别的php页面类型;
#service httpd restart----php安装完成;

1)下面编译安装php加速器xcache- 2.0.0
 
  
  1. #lftp 172.16.0.1 
  2. #cd pub/Sources/new_lamp/ 
  3. #get xcache-2.0.0.tar.bz2 -----下载xcache源码包;
  4. #bye 
  5. #tar xf xcache-2.0.0.tar.gz 
  6. #cd xcache-2.0.0 
  7. #/usr/local/php/bin/phpize----让php能识别xcache模块; 
  8. #./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 
  9. #make --编译;
  10. #make install--安装; 

2)编辑php.ini,整合phpxcache
 
  
  1. #mkdir /etc/php.d 
  2. #cp xcache.ini /etc/php.d----首先将xcache提供的样例配置导入php.ini; 
  3. #vim /etc/php.d/xcache.ini--接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行: 
  4. zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so 
  5. #service httpd restart---整合php和xcache完成;
说明:xcache.ini文件在xcache的源码目录中。

注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。

四:总结:
    以上就是LAMP的介绍及源码安装编译过程,鉴于作者的记忆力与能力有限,错误在所免,望朋友们给予指点