unbutu升級php和安裝php擴充外掛程式

來源:互聯網
上載者:User
ubuntu升級php和安裝php擴充

我想說的話:

雖然對已一個營運來說,升級個php安裝個擴充是很簡單的事情,但我還是把這次升級的過程完整記錄下來(每個外掛程式都帶有wget下載地址,這是我的初衷),這樣再次安裝擴充外掛程式時就省事多了,不至於每個外掛程式去趟官網找下載地址。

=======================廢話不多說,開始======================

php升級5.3.24到5.4.34
首先查看原版本的php編譯參數:

root@develop:~# /usr/local/php/bin/php -i | grep configure./configure  '--prefix=/usr/local/php-5.3.24/' \'--with-config-file-path=/usr/local/php-5.3.24/etc' \'--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' \'--with-zlib' '--enable-xml' '--with-curl' '--with-curlwrappers' \'--enable-mbregex' '--enable-mbstring' '--with-openssl' \'--enable-sockets' '--enable-zip' '--disable-ipv6' \'--with-pear' \'--enable-fpm' \'--with-fpm-user=www' \'--with-fpm-group=www' \'--with-mysql=/usr/local/mysql' \'--with-mysqli=mysqlnd' \'--enable-soap' \'--with-pdo-mysql' \'--enable-pcntl' \'--with-gd' '--with-xmlrpc' '--with-iconv' '--with-mcrypt'


升級php要注意php的編譯參數要相同。要帶上版本號碼,然後使用軟串連訪問。


開始升級:

cd /usr/local/src/wget http://cn2.php.net/distributions/php-5.4.34.tar.gztar zxf php-5.4.34.tar.gzcd php-5.4.34./configure  '--prefix=/usr/local/php-5.4.34/' \'--with-config-file-path=/usr/local/php-5.4.34/etc' \'--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' \'--with-zlib' '--enable-xml' '--with-curl' '--with-curlwrappers' \'--enable-mbregex' '--enable-mbstring' '--with-openssl' \'--enable-sockets' '--enable-zip' '--disable-ipv6' \'--with-pear' \'--enable-fpm' \'--with-fpm-user=www' \'--with-fpm-group=www' \'--with-mysql=/usr/local/mysql' \'--with-mysqli=mysqlnd' \'--enable-soap' \'--with-pdo-mysql' \'--enable-pcntl' \'--with-gd' '--with-xmlrpc' '--with-iconv' '--with-mcrypt'make

其中make步驟報錯如下:

ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':/home/king/php-5.2.13/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'collect2: ld returned 1 exit statusmake: *** [sapi/cli/php] Error 1

解決:參考:http://blog.csdn.net/sflsgfs/article/details/6318583
在安� PHP 到系統中時要是發生「undefined reference to libiconv_open'」之類的錯誤資訊,那表示在「./configure 」�抓好一些環境變數值。錯誤發生點在建立「-o sapi/cli/php」是出錯,沒�到要 link 的 iconv 函式庫參數。

解決方案:編輯Makefile 大約77 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最後加上 -liconv,
例如: EXTRA_LIBS = ..... -lcrypt -liconv
然後重新再次 make 即可。
繼續升級:

 make make install cd ..

編譯完成有如下提示:
Wrote PEAR system config file at: /usr/local/php-5.4.34/etc/pear.conf
You may want to add: /usr/local/php-5.4.34/lib/php to your php.ini include_path
/usr/local/src/php-5.4.34/build/shtool install -c ext/phar/phar.phar /usr/local/php-5.4.34/bin
ln -s -f /usr/local/php-5.4.34/bin/phar.phar /usr/local/php-5.4.34/bin/phar
Installing PDO headers: /usr/local/php-5.4.34/include/php/ext/pdo/

====================升級完成,開始配置php===========================


1) 拷貝源碼包目錄下的php.ini參考檔案到安裝目錄的etc目錄下

cp /usr/local/src/php-5.4.34/php.ini-production  /usr/local/php-5.4.34/etc/php.ini

修改php.ini參數(參考已有的5.3.24的php.ini)

2 )配置生產php-fpm設定檔

root@develop:/usr/local/php-5.4.34/etc# pwd/usr/local/php-5.4.34/etcroot@develop:/usr/local/php-5.4.34/etc# cp php-fpm.conf.default php-fpm1.conf

修改 php-fpm1.conf (參考已有的5.3.24的php-fpm1.conf)


3)配置完成後,建立軟串連

ln -s /usr/local/php-5.4.34/ /usr/local/php


4 )查看就版本安裝的php擴充,為新版本的php安裝擴充外掛程式


舊版本安裝的php安裝擴充如下:

extension=redis.soextension=eaccelerator.so;extension=memcached.soextension=memcache.soextension=gearman.soextension=trie_filter.soextension=mongo.so

======================開始安裝php擴充====================

1 redis擴充安裝

cd /usr/local/src/wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gztar zxf 2.2.4.tar.gzcd phpredis-2.2.4//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ..

檢查:(出現redis.so表示正確)

ll /usr/local/php-5.4.34/lib/php/extensions/no-debug-non-zts-20100525/


配置php支援:

vim /usr/local/php/etc/php.ini     #修改擴充模組路徑    extension_dir = "/usr/local/php-5.4.34/lib/php/extensions/no-debug-non-zts-20100525/"    # 添加支援    extension="redis.so"

重啟php和nginx(最後統一重啟)

2 安裝eaccelerator外掛程式

cd /usr/local/src/wget https://codeload.github.com/eaccelerator/eaccelerator/legacy.tar.gz/mastertar zxf mastercd eaccelerator-eaccelerator-42067ac//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ..echo 'include /usr/lib/php/modules/*.so' >>  /etc/ld.so.conf

修改/usr/local/php/ect/php.ini添加如下配置:

[eaccelerator]zend_extension_ts="/usr/local/php-5.4.34/lib/php/extensions/no-debug-non-zts-20100525/eaccelerator.so"eaccelerator.shm_size="32"eaccelerator.cache_dir="/tmp/eaccelerator"eaccelerator.enable="1"eaccelerator.optimizer="1"eaccelerator.check_mtime="1"eaccelerator.debug="0"eaccelerator.filter=""eaccelerator.shm_max="0"eaccelerator.shm_ttl="0"eaccelerator.shm_prune_period="0"eaccelerator.shm_only="0"eaccelerator.compress="1"eaccelerator.compress_level="9"

建立緩衝目錄:

mkdir -p /tmp/eacceleratorchmod 777 /tmp/eaccelerator

(重啟nginx php,最後統一重啟)


3 安裝memcache.so擴充

cd /usr/local/src/wget http://pecl.php.net/get/memcache-2.2.7.tgztar zxf memcache-2.2.7.tgzcd memcache-2.2.7//usr/local/php/bin/phpize./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dirmakemake installcd ..

(重啟nginx php,最後統一重啟)

4 安裝gearman擴充

cd /usr/local/src/wget http://pecl.php.net/get/gearman-1.1.2.tgztar zxf gearman-1.1.2.tgz cd gearman-1.1.2//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ..

(重啟nginx php,最後統一重啟)


5 安裝trie_filter擴充:
(該軟體不好下載,網路因素) 參考網址:http://www.codeweblog.com/用於檢測敏感詞的-php-擴充/

cd /usr/local/src/mkdir trie_filtercd trie_filter/wget https://as3chat.googlecode.com/files/trie_filter-2011-03-21.tar.gztar zxf trie_filter-2011-03-21.tar.gz/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installcd ..

(重啟nginx php,最後統一重啟)


6 安裝mongo擴充

cd /usr/local/src/wget http://pecl.php.net/get/mongo-1.4.5.tgztar zxf mongo-1.4.5.tgzcd mongo-1.4.5//usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config makemake installcd ..

7 擴充安裝完成檢查:

root@develop:/usr/local/src# ll /usr/local/php-5.4.34/lib/php/extensions/no-debug-non-zts-20100525/total 3380drwxr-xr-x 2 root root    4096 Jan 20 15:11 ./drwxr-xr-x 3 root root    4096 Jan 20 14:00 ../-rwxr-xr-x 1 root root  467380 Jan 20 14:13 eaccelerator.so*-rwxr-xr-x 1 root root  302505 Jan 20 14:39 gearman.so*-rwxr-xr-x 1 root root  265098 Jan 20 14:32 memcache.so*-rwxr-xr-x 1 root root 1445848 Jan 20 15:11 mongo.so*-rwxr-xr-x 1 root root  928238 Jan 20 14:00 redis.so*-rwxr-xr-x 1 root root   36722 Jan 20 14:54 trie_filter.so*

8 把已安裝的擴充外掛程式添加到php.ini

vim /usr/local/php/etc/php.ini


添加如下配置:

extension=redis.soextension=eaccelerator.so;extension=memcached.soextension=memcache.soextension=gearman.soextension=trie_filter.soextension=mongo.so

9 重啟nginx和php

10 調用phpinfo();來檢查

升級完畢。

  • 聯繫我們

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