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

Linux下搭建LAMP环境

[日期:2012-05-04] 来源:Linux社区  作者:flykite [字体: ]
关于部署LAMP环境,晚上有很多资料,版本都大同小异,这里总结一下我在生产环境中进行LAMP部署时候的最基本配置,不包含参数调优部分,仅供大家参考。

    1. 安装Apache

  1. #!/bin/bash  
  2.  
  3. groupadd htdocs  
  4. useradd -g htdocs htdocs  
  5.  
  6. tar zxvf httpd-2.2.14.tar.gz  
  7. cd httpd-2.2.14  
  8. ./configure --prefix=/usr/local/apache --enable-modules=most --enable-mods-shared=all --enable-rewrite --enable-so  
  9. make && make install  
  10. cd .. 

    2. 安装MySQL

  1. #!/bin/bash  
  2.  
  3. groupadd mysql  
  4. useradd -g mysql mysql  
  5.  
  6. tar zxvf mysql-5.1.45.tar.gz  
  7. cd mysql-5.1.45  
  8. ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --enable-assembler --enable-profiling --enable-local-infile --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=complex --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-big-tables --with-plugins=partition,federated,innobase  
  9. make && make install  
  10. cd ..  
  11.  
  12. /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql  
  13.  
  14. chgrp -R mysql /usr/local/mysql  
  15. chown -R mysql /usr/local/mysql/data  
  16.  
  17. echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf.d/mysql.conf  
  18. ldconfig -v  
  19.  
  20. mkdir /usr/local/mysql/etc  
  21.  
  22. /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --datadir=/usr/local/mysql/data --user=mysql &  
  23. # /usr/local/mysql/bin/mysqladmin shutdown  
  24.  
  25. export PATH=$PATH:/usr/local/mysql/bin  
  26. echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile 

    3. 安装Oracle

  1. #!/bin/bash  
  2.  
  3. if [ `getconf LONG_BIT` == 64 ]; then 
  4.     rpm -Uvh x86_64/oracle-instantclient-basic-10.2.0.4-1.i386.rpm  
  5.     rpm -Uvh x86_64/oracle-instantclient-devel-10.2.0.4-1.i386.rpm  
  6.     rpm -Uvh x86_64/oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm  
  7.     ln -s /usr/include/oracle/10.2.0.4/client64  /usr/lib/oracle/10.2.0.4/client64/include  
  8. else 
  9.     rpm -Uvh i386/oracle-instantclient-basic-10.2.0.4-1.i386.rpm  
  10.     rpm -Uvh i386/oracle-instantclient-devel-10.2.0.4-1.i386.rpm  
  11.     rpm -Uvh i386/oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm  
  12.     ln -s /usr/include/oracle/10.2.0.4/client  /usr/lib/oracle/10.2.0.4/client/include  
  13. fi  
  14.  
  15. mkdir -p /usr/lib/oracle/10.2.0.4/network/admin  
  16. touch /usr/lib/oracle/10.2.0.4/network/admin/tnsnames.ora 

    4. 安装PHP

  1. #!/bin/bash  
  2.  
  3. # yum -y install curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel zlib zlib-devel freetype freetype-devel openldap openldap-devel xmlrpc  
  4.  
  5. if [ `getconf LONG_BIT` == 64 ]; then 
  6.     yum -y install curl.i386 curl-devel.i386 libxml2.i386 libxml2-devel.i386 libjpeg.i386 libjpeg-devel.i386 libpng.i386 libpng-devel.i386 zlib.i386 zlib-devel.i386 freetype.i386 freetype-devel.i386 openldap.i386 openldap-devel.i386 xmlrpc.i386  
  7.     yum -y install curl.x86_64 curl-devel.x86_64 libxml2.x86_64 libxml2-devel.x86_64 libjpeg.x86_64 libjpeg-devel.x86_64 libpng.x86_64 libpng-devel.x86_64 zlib.x86_64 zlib-devel.x86_64 freetype.x86_64 freetype-devel.x86_64 openldap.x86_64 openldap-devel.x86_64 xmlrpc.x86_64  
  8. else 
  9.     yum -y install curl.x86_64 curl-devel.x86_64 libxml2.x86_64 libxml2-devel.x86_64 libjpeg.x86_64 libjpeg-devel.x86_64 libpng.x86_64 libpng-devel.x86_64 zlib.x86_64 zlib-devel.x86_64 freetype.x86_64 freetype-devel.x86_64 openldap.x86_64 openldap-devel.x86_64 xmlrpc.x86_64  
  10. fi  
  11.  
  12. tar zxvf gd-2.0.33.tar.gz  
  13. cd gd-2.0.33  
  14. ./configure --prefix=/usr  
  15. make && make install  
  16. cd ..  
  17.  
  18. tar zxvf libmcrypt-2.5.8.tar.gz  
  19. cd libmcrypt-2.5.8  
  20. ./configure --prefix=/usr  
  21. make && make install  
  22. cd libltdl/  
  23. ./configure --prefix=/usr --enable-ltdl-install  
  24. make && make install  
  25. cd ../..  
  26.  
  27. tar zxvf mhash-0.9.9.9.tar.gz  
  28. cd mhash-0.9.9.9  
  29. ./configure --prefix=/usr  
  30. make && make install  
  31. cd ..  
  32.  
  33. tar zxvf freetds-0.64.tar.gz  
  34. cd freetds-0.64  
  35. ./configure --prefix=/usr/local/freetds --enable-msdblib --with-gnu-ld --with-tdsver=8.0  
  36. make && make install  
  37. cd ..  
  38.  
  39. echo "/usr/local/freetds/lib" >> /etc/ld.so.conf.d/freetds.conf  
  40. ldconfig -v  
  41.  
  42. tar zxvf php-5.2.6.tar.gz  
  43. cd php-5.2.6  
  44. if [ `getconf LONG_BIT` == 64 ]; then 
  45.     ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --enable-bcmath --with-curl --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --with-ldap --enable-mbstring --with-mcrypt --with-mhash --with-mssql=/usr/local/freetds --with-mysql=/usr/local/mysql --enable-pcntl --with-pdo-mysql=/usr/local/mysql --with-pdo-oci=/usr/lib/oracle/10.2.0.4/client64 --enable-soap --enable-sockets --with-xmlrpc  
  46. else 
  47.     ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --enable-bcmath --with-curl --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --with-ldap --enable-mbstring --with-mcrypt --with-mhash --with-mssql=/usr/local/freetds --with-mysql=/usr/local/mysql --enable-pcntl --with-pdo-mysql=/usr/local/mysql --with-pdo-oci=/usr/lib/oracle/10.2.0.4/client --enable-soap --enable-sockets --with-xmlrpc  
  48. fi  
  49. make && make install  
  50. cd .. 

    由于文章的篇幅管理,这里就不列举相关配置信息了,关于httpd.conf、my.cnf以及php.ini文件的配置,��供了下载地址:

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2012年资料/5月/4日/Linux下搭建LAMP环境/

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

       

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