溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

CentOS 編譯安裝php5.5, 并配制支持apach,nignx核心代碼

發(fā)布時(shí)間:2020-06-20 11:30:06 來(lái)源:網(wǎng)絡(luò) 閱讀:330 作者:jamesrh 欄目:web開(kāi)發(fā)

首先是編譯準(zhǔn)備工作:

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/mirror
tar -xvf php-5.5.5.tar.gz
cd php-5.5.5

編譯安裝 php 5.5 的參數(shù):

./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

我已經(jīng)盡量的在參數(shù)上做了精簡(jiǎn),用以上參數(shù)編譯安裝好的 php 運(yùn)行 wordpress, joomla, ip board 等常見(jiàn)的博客、論壇程序都是沒(méi)有問(wèn)題的,因?yàn)橛辛?--disable-cli,所以就沒(méi)法 make test 了,安裝好以后也沒(méi)法 php -v 了。安裝吧:

make
make install
cp php.ini-production /usr/local/lib/php.ini
#記住上面 php.ini 的位置哦。


如是apache, 配制 apache 


是時(shí)候讓 apache 知道有 php 的存在了,在 apache 配置文件 httpd.conf 中添加:

LoadModule php5_module modules/libphp5.so
#上面那行可能在編譯安裝 php 的過(guò)程中已經(jīng)由系統(tǒng)自動(dòng)添加了
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

OK!重啟 apache,人品好的人是不會(huì)出現(xiàn)問(wèn)題的。



如是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行的參數(shù),改為$document_root$fastcgi_script_name,或者使用絕對(duì)路徑
service nginx restart #重啟nginx




向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI