Centos源代碼編譯安裝PHP

PHP的安裝步驟,版本爲5.3.X

1、 centos已經完成系統初始化,已經安裝編譯安裝gcc、make等工具。

2、 下載PHP源碼包,解壓

3、 安裝必要的支持包,否則生產環境下將會出現很多問題,不支持很多功能。

yum -y install libxml2  libxml2-devel

yum -y install libcurl  curl-devel

yum -y install libjpeg  libjpeg-devel

yum -y install libpng   libpng-devel

yum -y install freetype freetype-devel

yum -y install glibc    glibc-devel glib2 glib2-devel

yum -y install ncurses  openssl-devel

yum -y install libmcrypt libmcrypt-devel

yum -y install bzip2 

如果configure提示缺少去其它的安裝依賴包,先檢查系統中是否已經安裝。如果沒有,則使用yum或者源碼編譯安裝。如libiconv也經常找不到庫文件。

4、 配置

# ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=daemon --with-fpm-group=daemon--with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-iconv-dir  --with-freetype-dir  --with-jpeg-dir  --with-png-dir  --with-gd --with-zlib --with-libxml-dir --with-curl --with-curlwrappers  --with-mhash  --with-xmlrpc --with-mcrypt --with-openssl --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-gd-native-ttf --enable-ftp  --enable-pcntl  --enable-sockets  --enable-zip --enable-soap  --disable-debug  --disable-ipv6

注意安裝檢查是否有缺少軟件包提示。

5、 編譯安裝

先用top命令檢查cpu的核數,如果系統的核數爲8

make選項可以爲

#make -j 8

#make test

#make install

注意make是否產生錯誤,一些警告可以忽略

6、 設置開機啓動

拷貝SystemV腳本

#cpphp.ini-production /usr/local/php/etc/php.ini

#cp sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm

#chmod a+x/etc/init.d/php-fpm

#vim /etc/rc.local

加入/etc/init.d/php-fpm start

7、 添加Mongdb、Memcache擴展

#/usr/local/php/bin/pcelinstall mongo

#/usr/local/php/bin/pcelinstall mencache

8、 添加加速模塊Eaccelerator(PHP5.5版本開機不用加速擴展)

tar解壓eaccelerator安裝包

進入源文件目錄,用phpize生成configure配置文件

#/usr/local/php/bin/phpize

配置

#./configure --with-php-config=/usr/local/php/bin/php-config--enable-eaccelerator=shared

#make

#make install

9、 查看PHP-FPM是否正常工作

#/etc/init.d/php-fpmstart

#ps -ef | grep php   查看php-fpm進程

10、修改php.ini和php-fpm.confg文件,適合服務器與應用要求

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章