CentOS下安裝php5.3

來源:互聯網
上載者:User

作業系統:CentOS5.6

環境:Apache2.2安裝成功、可查看:http://blog.csdn.net/dabao_java/article/details/24854719

         Mysql5.5已經安裝成功、可查看:http://blog.csdn.net/dabao_java/article/details/25022215

1.下載php源碼
   http://www.php.net/downloads.php
2.選擇: php-5.3.28.tar.gz
3.下載完成後上傳到linux的/root檔案夾
4.cd /root
tar -zxvf php-5.3.28.tar.gz
cd php-5.3.28
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml
提示:configure: error: xml2-config not found. Please check your libxml2 installation.
建議在安裝PHP之前,應先安裝PHP5需要的最新版本庫檔案,例如libxml2、libmcrypt以及GD2庫等檔案。安裝GD2庫是為了讓 PHP5支 持GIF、PNG和JPEG圖片格式,所以在安裝GD2庫之前還要先安裝最新的zlib、libpng、freetype和jpegsrc等庫檔案。

autoconf-2.61.tar.gz
freetype-2.3.5.tar.gz
gd-2.0.35.tar.gz
jpegsrc.v6b.tar.gz
libmcrypt-2.5.8.tar.gz
libpng-1.2.31.tar.gz
libxml2-2.6.30.tar.gz
zlib-1.2.3.tar.gz
ZendOptimizer-3.2.6-linux-glibc21-i386.tar.gz
phpMyAdmin-3.0.0-rc1-all-languages.tar.gz5. 
安裝 libxml2-2.7.8.tar.gz
libxml2-2.7.8.tar.gz
下載:http://download.chinaunix.net/download.php?id=35177&ResourceID=6095
Cd /root
Tar –zxvf libxml2-2.7.8.tar.gz
Cd  libxml2-2.7.8
./configure  --prefix=/usr/local/libxml2/
//可能提示安裝失敗
rpm -aq|grep -i libxml查看系統是否已經安裝
libxml2安裝中出現的錯誤:
cannot remove `libtoolT': No such file or directory
解決方案:
修改configure檔案
$ vim configure
刪除這一行: $RM "$cfgfile"
重新再運行 $ ./configure

Make
Make install

從新執行:
 
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-
path=/usr/local/php5/etc/php.ini --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-
mysql=mysqlnd --without-pdo-sqlite --without-sqlite3 --without-sqlite --enable-mbstring  --with-
openssl --with-mhash --with-mcrypt --with-gettext --with-zlib-dir=/usr/local/zlib --enable-zip --
enable-sockets --enable-soap --with-xmlrpc --with-libxml-dir--with-zlib=/usr/local/zlib/ --with-mysql=/usr/local/mysql --with-mcrypt
Make install 成功:
5.配置apache和php整合
    cp /usr/local/src/php-5.3.16/php.ini-development  /usr/local/php/lib/php.ini
    把原來位於原始碼裡面的php.ini-development拷貝到/usr/local/php/lib/php.ini下,並且重新命名為php.ini
#設定apache的預設檔案名稱次序  
  #AddType application/x-httpd-php .php .phtml .php3 .inc
  #AddType application/x-httpd-php-source .phps
  #設定php檔案尾碼  
  存檔退出   
  vi /usr/local/lib/php.ini
  #register-golbals = On
  存檔退出

 
 6.測試php
測試:編寫test.php檔案,內容如下:
<?php phpinfo(); ?>
瀏覽器輸入:http://127.0.0.1/test.php
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.