Centos 6.6系統下編譯安裝PHP5.6.8相關教程

來源:互聯網
上載者:User

Centos 6.6系統下編譯安裝PHP5.6.8相關教程

(Apache和MySQL的安裝在前面的部落格也有詳細介紹)

首先準備幾個安裝包

libmcrypt-2.5.8.tar.gz(http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/)

php-5.6.2.tar.gz (http://cn2.php.net/downloads.php)

1.首先添加依賴應用
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel

這一步是為了支援一些php啟動並執行東西,還有以下編譯需要的

2.安裝加密擴充庫
cd /usr/local/src/
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install

3.到php壓縮包存放的目錄下

tar zxvf php-5.6.8.tar.gz #解壓
cd php-5.6.8 #進入檔案夾

運行

[root@VPS php-5.6.8]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysql-sock --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-fpm --with-ncurses --enable-soap --with-libxml-dir --with-XMLrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear

這一步不能有錯誤,警告可能會有,是說某些包不能識別之類的,一般沒有很大問題

執行

make

顯示

Build complete.
Don't forget to run 'make test'.

【

如果顯示:undefined reference to `ts_resource_ex'

collect2: ld returned 1 exit status
make: *** [sapi/cli/php] 錯誤 1

出現這樣的錯誤資訊是我之前用不同的參數編譯過PHP。

解決方案:執行make clean刪除上次的編譯結果,然後再重新編譯就OK了。

如果是你第一次編譯就出現這樣的錯誤,百度解決。

】

執行

make install

最後就是配置apache讓它支援php


修改apache的設定檔httpd.conf

vi /usr/local/apache/conf/httpd.conf

然後在文本最後面添加

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

(注意,在apache安裝目錄下,modules下有libphp5.so,這是php安裝時添加進去的,如果沒有,php,你需要重裝下

產生libphp5.so檔案的是./configure中的這段代碼--with-apxs2=/usr/local/apache/bin/apxs,路徑要和你安裝的路徑對應

)


接下來複製php開機檔案


cp php-5.6.3/php.ini-development /usr/local/php/lib/php.ini


儲存,重新啟動


service httpd start


如果沒有報錯則說明啟動成功


測試php是否安裝成功


寫一個簡單的php頁面


<?php
phpinfo();
?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.