1. 程式人生 > >linux編譯安裝php

linux編譯安裝php

1,到php官網下載合適的版本,這裡選擇5.6

2,tar -xzvf php-5.6.33.tar.gz #解壓

3,cd php-5.6.33

4,./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-mysql --with-mysqli --with-pdo-mysql --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline

#配置編譯環境,當中可能會出錯,但別擔心,報錯的基本是告訴你哪些依賴沒安裝,根據錯誤資訊去安裝相應的依賴包就可以了,如果一切順利,出現"thanks use php",就可以開始第5步了。

5,make && make install #編譯並安裝php,如果成功你就可以看到目錄/usr/local/下多了php56,如果沒看到說明安裝失敗了,輸入make clean && make clean all,重新從第4步安裝。

6,根據使用的伺服器nginx/apache作相應配置即可。