1. 程式人生 > >ubuntu原始碼編譯安裝php

ubuntu原始碼編譯安裝php

常見的快速安裝php及相關模組的是直接安裝php-devel,即sudo apt-get install php5-dev.

獲取PHP原始碼:

wget http://cn2.php.net/get/php-5.5.9.tar.gz/from/this/mirror

依賴庫安裝:

sudo apt-get install libxml2-dev
sudo apt-get install libcurl3-openssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libbz2-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libxpm-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libt1-dev
sudo apt-get install libmcrypt-dev
sudo apt-get install libmysql++-dev
sudo apt-get install libxslt1-dev

配置安裝:

./configure --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir --with-openssl

make make install

注:編譯安裝php後php-fpm也會安裝,預設路徑在/usr/local/sbin/php-fpm,這與apt-get install是不一致的,需要自行啟動php-fpm

啟動命令為sudo /usr/local/sbin/php-fpm,出錯,找不到檔案php-fpm.conf,事實上在/usr/local/etc/下存在php-fpm.conf.default

修改檔名,重新拷貝一份即可:cp php-fpm.conf.default php-fpm.conf

然後啟動sudo /usr/local/sbin/php-fpm

若仍然出錯[pool www] cannot get gid for group 'nobody'

則修改php-fpm.conf中user和group欄位為www-data即可

注意 不要與apt-get install php-fpm安裝的php-fpm衝突!!!