centos 下搭建 php环境(1)

3、PHP的安装

安装GD库(让PHP支持GIF,PNG,JPEG)

首先下载 jpeg6,libpng,freetype 并安装模块

wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz

wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz

wget http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.9.tar.gz

wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz

安装 jpeg6

建立目录

  1. # mkdir /usr/local/jpeg6  
  2.  
  3. # mkdir /usr/local/jpeg6/bin  
  4.  
  5. # mkdir /usr/local/jpeg6/lib  
  6.  
  7. # mkdir /usr/local/jpeg6/include  
  8.  
  9. # mkdir /usr/local/jpeg6/man  
  10.  
  11. # mkdir /usr/local/jpeg6/man/man1  
  12.  
  13. # cd /tmp  
  14.  
  15. # tar -zxf jpegsrc.v6b.tar.gz  
  16.  
  17. # cd jpeg-6b  
  18.  
  19. # ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static  
  20.  
  21. # make; make install  
  22.  

安装libpng

  1. # cd /tmp  
  2.  
  3. # tar -zxf libpng-1.2.8.tar.gz  
  4.  
  5. # cd libpng-1.2.8  
  6.  
  7. # cp scrīpts/makefile.std makefile  
  8.  
  9. # make; make install  
  10.  

安装 freetype

  1. # cd /root/soft  
  2.  
  3. # tar -zxf freetype-2.1.10.tar.gz  
  4.  
  5. # cd freetype-2.1.10  
  6.  
  7. # ./configure --prefix=/usr/local/freetype  
  8.  
  9. # make;make install  
  10.  

安装最新的GD库

  1. # cd /tmp  
  2.  
  3. # tar -zxf gd-2.0.33.tar.gz  
  4.  
  5. # cd gd-2.0.33  
  6.  
  7. # ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/  
  8.  
  9. # make; make install  
  10.  

由于php5需libxml2的支持, 所以先下载并安装libxml2

  1. # cd /tmp  
  2.  
  3. # wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.30.tar.gz  
  4.  
  5. # tar -zxf libxml2-2.6.19.tar.gz  
  6.  
  7. # cd libxml2-2.6.19  
  8.  
  9. # ./configure --prefix=/usr/local/libxml2  
  10.  
  11. # make; make install  
  12.  

安装 libxslt

  1. # cd /tmp  
  2.  
  3. # wget http://ftp.gnome.org/pub/gnome/sources/libxslt/1.1/libxslt-1.1.22.tar.gz  
  4.  
  5. # tar -zxf libxslt-1.1.22.tar.gz  
  6.  
  7. # cd libxslt-1.1.22  
  8.  
  9. # ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2  
  10.  
  11. # make; make install  
  12.  

终于要安装PHP了:

  1. # tar -zxf php-5.2.3.tar.gz  
  2.  
  3. # cd php-5.2.3  
  4.  
  5. # ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring  
  6.  
  7. # make  
  8.  
  9. # make install  
  10.  

其中./configure 后的

--prefix=/usr/local/php5

--with-apxs2=/usr/local/apache/bin/apxs

--with-mysql=/usr/local/mysql/

--with-libxml-dir=/usr/local/libxml2

是必要的选项

--with-gd=/usr/local/gd2/

--with-jpeg-dir=/usr/local/jpeg6/

--with-png

--with-zlib-dir=/usr/lib

--with-freetype-dir=/usr/local/freetype

这是让PHP支持GD库的配置选项

配置 httpd.conf 让apache支持PHP

  1. # vi /usr/local/apache/conf/httpd.conf  
  2.  

找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps在你Web目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确

安装 phpmyadmin

下载

  1. # tar zxvf phpMyAdmin-2.11.2-all-languages.tar.gz  
  2.  
  3. # mv phpMyAdmin-2.11.2-all-languages /usr/local/httpd/htdocs/phpmyadmin  
  4.  
  5. # cd /usr/local/httpd/htdocs/phpmyadmin  
  6.  
  7. # cp ./libraries/config.default.php ./config.inc.php  
  8.  
  9. #vi config.inc.php  
  10.  
  11. $cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin';  
  12.  
  13. $cfg['Servers'][$i]['auth_type'] = 'http';  
  14.  

安装zend:

  1. # tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz  
  2.  
  3. # cd ZendOptimizer-3.2.2-linux-glibc21  
  4.  
  5. # ./install.sh  
  6.  

OK,CentOS下LAMP安装成功~!

 

posted @ 2014-04-19 14:05  timelesszhuang  阅读(227)  评论(0编辑  收藏  举报