標籤:官方下載 local
首先是編譯準備工作:
yum groupinstall "Development tools"
然後是編譯安裝 PHP 5.5.x 需要用到的 devel 包:
yum install libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel
從官方下載,解壓:
wget http://us3.php.net/get/php-5.5.5.tar.gz/from/cn2.php.net/mirrortar -xvf php-5.5.5.tar.gzcd php-5.5.5
編譯安裝 php 5.5 的參數:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --disable-cli --enable-shared --with-libxml-dir --with-gd --with-openssl --enable-mbstring --with-mcrypt --with-mysqli --with-mysql --enable-opcache --enable-mysqlnd --enable-zip --with-zlib-dir --with-pdo-mysql --with-jpeg-dir --with-freetype-dir --with-curl --without-pdo-sqlite --without-sqlite3
我已經盡量的在參數上做了精簡,用以上參數編譯安裝好的 php 運行 wordpress, joomla, ip board 等常見的部落格、論壇程式都是沒有問題的,因為有了 --disable-cli,所以就沒法 make test 了,安裝好以後也沒法 php -v 了。安裝吧:
makemake installcp php.ini-production /usr/local/lib/php.ini#記住上面 php.ini 的位置哦。
如是apache, 配製 apache
是時候讓 apache 知道有 php 的存在了,在 apache 設定檔 httpd.conf 中添加:
LoadModule php5_module modules/libphp5.so#上面那行可能在編譯安裝 php 的過程中已經由系統自動添加了<FilesMatch \.php$>SetHandler application/x-httpd-php</FilesMatch>
OK!重啟 apache,人品好的人是不會出現問題的。
如是nignx, 配製 nignx
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak #備份原有設定檔vi /etc/nginx/conf.d/default.conf #編輯
index index.php index.html index.htm; #增加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
#取消FastCGI server部分location的注釋,並要注意fastcgi_param行的參數,改為$document_root$fastcgi_script_name,或者使用絕對路徑
service nginx restart #重啟nginx
CentOS 編譯安裝php5.5, 並配製支援apach,nignx核心代碼