CentOS 5.x源码编译使用lamp一键安装

http://www.itjxue.com  2015-06-14 10:55  来源:未知  点击次数: 

源码编译安装LAMP虽然过程繁琐,但可以根据自己PHP程序的需要配置相应的环境,非常的灵活。对于比较急于配置好LAMP的同学,可以使用lamp一键安装

卸载yum或rpm安装的amp软件

  1. rpm -qa|grep httpd
  2. rpm -e httpd
  3. rpm -qa|grep mysql
  4. rpm -e mysql
  5. rpm -qa|grep php
  6. rpm -e php
  7.  
  8. yum -y remove httpd
  9. yum -y remove php
  10. yum -y remove mysql-server mysql
  11. yum -y remove php-mysql
  12.  
  13. yum -y install yum-fastestmirror
  14. yum -y remove httpd
  15. yum -y update

禁用SeLinux

  1. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

yum安装必要工具

  1. yum -y install gcc gcc-c++ libtool-libs autoconf freetype freetype-devel gd libjpeg libjpeg-devel libmcrypt libmcrypt-devel libpng libpng-devel libxml2 libxml2-devel ncurses ncurses-devel zlib zlib-devel zip unzip curl curl-devel

下载所需源码

  1. mkdir /lamp
  2. cd /lamp
  3. wget -c http://apache.ziply.com//httpd/httpd-2.2.21.tar.gz
  4. wget -c http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.59.tar.gz/from/http://mysql.he.net/
  5. wget -c http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror
  6. wget -c http://superb-dca2.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.5/phpMyAdmin-3.4.5-all-languages.tar.gz
  7. tar xzf httpd-2.2.21.tar.gz
  8. tar xzf mysql-5.1.59.tar.gz
  9. tar xzf php-5.2.17.tar.gz
  10. tar xzf phpMyAdmin-3.4.5-all-languages.tar.gz

安装apache2.2.21

  1. cd /lamp/httpd-2.2.21
  2. ./configure --prefix=/usr/local/apache/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
  3. make
  4. make install
  5. cp build/rpm/httpd.init /etc/init.d/httpd
  6. chmod 755 /etc/init.d/httpd
  7. chkconfig --add httpd
  8. chkconfig --level 35 httpd on
  9. cd /etc
  10. mv httpd httpd_old
  11. ln -s /usr/local/apache/ httpd
  12. cd /usr/sbin/
  13. ln -fs /usr/local/apache/bin/httpd
  14. ln -fs /usr/local/apache/bin/apachectl
  15. cd /var/log
  16. rm -rf httpd/
  17. ln -s /usr/local/apache/logs httpd
  18. groupadd apache
  19. useradd -g apache apache

在httpd.conf文件找到daemon,修改为apache
增加如下代码到httpd.conf文件:

  1. <Location />
  2. AddOutputFilterByType DEFLATE text/plain
  3. AddOutputFilterByType DEFLATE text/css
  4. AddOutputFilterByType DEFLATE application/xml
  5. AddOutputFilterByType DEFLATE application/rss+xml
  6. AddOutputFilterByType DEFLATE application/atom_xml
  7. AddOutputFilterByType DEFLATE application/x-javascript
  8. AddOutputFilterByType DEFLATE application/x-httpd-php
  9. AddOutputFilterByType DEFLATE text/html
  10. </Location>

安装mysql5.1.59

  1. groupadd mysql
  2. useradd -g mysql mysql
  3. cd /lamp/mysql-5.1.59
  4. ./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all
  5. make
  6. make install
  7.  
  8. cp support-files/my-medium.cnf /etc/my.cnf
  9. sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
  10. sed -i 's/^log-bin=mysql-bin/#log-bin=mysql-bin/g' /etc/my.cnf
  11. sed -i 's/^binlog_format=mixed/#binlog_format=mixed/g' /etc/my.cnf
  12. echo "skip-innodb" >> /etc/my.cnf
  13. echo "skip-bdb" >> /etc/my.cnf
  14. /usr/local/mysql/bin/mysql_install_db --user=mysql
  15. chown -R root /usr/local/mysql
  16. chown -R mysql /usr/local/mysql/var
  17. chgrp -R mysql /usr/local/mysql
  18.  
  19. /usr/local/mysql/bin/mysqld_safe --user=mysql &
  20.  
  21. cp /lamp/mysql-5.1.59/support-files/mysql.server /etc/rc.d/init.d/mysqld
  22. chown root.root /etc/rc.d/init.d/mysqld
  23. chmod 755 /etc/rc.d/init.d/mysqld
  24. chkconfig --add mysqld
  25. chkconfig --list mysqld
  26. chkconfig --levels 245 mysqld off
  27. ln -s /usr/local/mysql/bin/mysql /usr/bin
  28. ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
  29. service mysqld start
  30. /usr/local/mysql/bin/mysqladmin -u root password '新密码'

安装PHP5.2.17

  1. cd /lamp/php-5.2.17
  2. ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-zlib -with-zlib-dir=/usr --with-libxml-dir=/usr --with-jpeg-dir --with-freetype-dir --with-gd --enable-gd-native-ttf --with-curl --enable-zip --with-mcrypt=/usr --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
  3. make
  4. make install
  5.  
  6. cp php.ini-dist /usr/local/php/etc/php.ini
  7. sed -i '/\s\s*AddType.*tgz$/a\ Addtype application/x-httpd-php .php .phtml' /etc/httpd/conf/httpd.conf
  8. service httpd restart

安装ZendOptimizer-3.3.9(可选)

64位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
32位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

  1. cd /lamp
  2. wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
  3. tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
  4. cd /lamp/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/
  5. mkdir -p /usr/local/Zend/lib/
  6. cp ZendOptimizer.so /usr/local/Zend/lib
  7.  
  8. sed -i '$a\[zend]\
  9. zend_optimizer.optimization_level=15\
  10. zend_extension=/usr/local/Zend/lib/ZendOptimizer.so' /usr/local/php/etc/php.ini
  11.  
  12. service httpd restart

安装eAccelerator-0.9.6.1(可选)

  1. cd /lamp
  2. wget http://voxel.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
  3. unzip eaccelerator-0.9.6.1.zip
  4. cd eaccelerator-0.9.6.1
  5. export PHP_PREFIX="/usr/local/php"
  6. $PHP_PREFIX/bin/phpize
  7. ./configure -enable-eaccelerator=shared -with-php-config=$PHP_PREFIX/bin/php-config
  8. make && make install
  9. cd /tmp
  10. mkdir eaccelerator
  11. chmod 0777 eaccelerator
  12.  
  13. sed -i '/^\[zend]$/i\
  14. [eaccelerator]\
  15. zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"\
  16. eaccelerator.shm_size="32"\
  17. eaccelerator.cache_dir="/tmp/eaccelerator"\
  18. eaccelerator.enable="1"\
  19. eaccelerator.optimizer="1"\
  20. eaccelerator.check_mtime="1"\
  21. eaccelerator.debug="0"\
  22. eaccelerator.filter=""\
  23. eaccelerator.shm_max="0"\
  24. eaccelerator.shm_ttl="0"\
  25. eaccelerator.shm_prune_period="0"\
  26. eaccelerator.shm_only="0"\
  27. eaccelerator.compress="1"\
  28. eaccelerator.compress_level="9" ' /usr/local/php/etc/php.ini
  29.  
  30. service httpd restart

安装phpmyadmin-3.4.5(可选)

  1. cd /lamp
  2. mv phpMyAdmin-3.4.5-all-languages /etc/httpd/htdocs/phpmyadmin
  3. chmod -R 755 /etc/httpd/htdocs/phpmyadmin
  4. chown -R apache:apache /etc/httpd/htdocs/phpmyadmin
  5. cd /etc/httpd/htdocs/phpmyadmin
  6. cp config.sample.inc.php config.inc.php
  7. sed -i 's/'cookie'/'http'/g' config.inc.php
  8. sed -i "/\?>/i\$cfg['ZipDump'] = TRUE" config.inc.php
  9. sed -i '$a\Alias /phpmyadmin "/etc/httpd/htdocs/phpmyadmin/"' /etc/httpd/conf/httpd.conf
除非注明,IT教学网文章均为原创,转载请以链接形式标明本文地址

(责任编辑:IT教学网)

更多

推荐linux文章