CentOS 編譯安裝php5.5, 並配製支援apach,nignx核心代碼

來源:互聯網
上載者:User

標籤:官方下載   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核心代碼

聯繫我們

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