CentOS7安裝PHP開發環境2-源碼安裝PHP

OS:CentOS 7
PHP:7.1.6、7.2.1

新建用戶www

[root@sy-pc ~]# useradd www -s /sbin/nologin -M

編譯

(–enable-maintainer-zts 線程安全模式)
(較少的配置)注意:--enable-fpm
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-phpdbg --with-openssl --enable-zip --enable-mysqlnd --with-mysqli

(較多的配置-線程安全模式)注意:--enable-fpm --enable-maintainer-zts --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-maintainer-zts --enable-phpdbg --enable-phpdbg-debug --enable-debug --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

(較多的配置-線程不安全模式)
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-acl --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-gcov --with-tsrm-st --with-tsrm-pthreads --enable-mod-charset --enable-roxen-zts --enable-sigchild --enable-libgcc --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

(無opcache debug)
注意:--enable-fpm --enable-maintainer-zts
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --with-fpm-acl --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-gcov --enable-maintainer-zts --with-tsrm-st --with-tsrm-pthreads --enable-mod-charset --enable-roxen-zts --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

(很多庫已經安裝過了。)
./configure --prefix=/application/php-7 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --with-fpm-acl --with-curl --with-iconv --with-mcrypt --with-mhash --enable-bcmath --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-roxen-zts --enable-maintainer-zts --enable-debug --enable-mod-charset --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local && make && make install

(php 7.1.8)

注意:--enable-fpm --with-fpm-acl --enable-maintainer-zts --disable-inline-optimization --disable-zend-signals --with-gnu-ld
./configure --prefix=/application/php-7.1.8 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --with-fpm-acl --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-gcov --enable-debug --enable-sigchild --enable-libgcc --enable-dmalloc --enable-dtrace --enable-fd-setsize --with-system-ciphers --with-pcre-jit --enable-bcmath --enable-calendar --enable-dba --enable-exif --with-pcre-dir --enable-ftp --enable-gd-native-ttf --enable-gd-jis-conv --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local --enable-intl --enable-mbstring --enable-embedded-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zip --enable-mysqlnd --enable-maintainer-zts --disable-inline-optimization --disable-zend-signals --with-tsrm-st --with-tsrm-pthreads --with-gnu-ld --with-pic

(php 7.2.1)

注意:--enable-maintainer-zts --with-tsrm-pthreads

./configure --prefix=/application/php-7.2.1 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-acl --with-curl --with-iconv --with-bz2 --with-mhash --enable-bcmath --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-maintainer-zts --with-tsrm-pthreads --enable-debug --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-zlib --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

編譯時的錯誤解決方案:https://blog.csdn.net/u011608531/article/details/50756112

# make && make install

安裝報錯:
Wrote PEAR system config file at: /application/php-7.2.1/etc/pear.conf
You may want to add: /application/php-7.2.1/lib/php to your php.ini include_path
/wwwroot/package/php-7.2.1/build/shtool install -c ext/phar/phar.phar /home/sy/local/php7.2.1/bin
cp -pR -f phar.phar /application/php-7.2.1/bin/phar
cp: cannot stat ‘phar.phar’: No such file or directory
make: *** [install-pharcmd] Error 1

(php 7.3.0)

Libzip 版本過低或提示reinstall解決方法 http://www.kwx.gd/PHPEnvironment/CetnOS-libzip.html
centos安裝Libzip https://blog.csdn.net/oxiaobaio/article/details/80854054

./configure --prefix=/application/php-7.3.0 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-acl --with-curl --with-iconv --with-bz2 --with-mhash --enable-bcmath --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-maintainer-zts --with-tsrm-pthreads --enable-debug --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-zlib --with-zlib-dir=/usr/local --with-libzip=/usr/local --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

報錯:
Protected multilib versions
解決方案:
https://blog.csdn.net/shouldnotappearcalm/article/details/64212868?utm_source=blogxgwz3
yum install -y zlib zlib-devel --setopt=protected_multilib=false

安裝後創建軟連接

# ln -s /application/php-具體版本號 /application/php

設置目錄所屬用戶、所屬用戶組

# chown www:www -R /application/php/

注意:上一句的/application/php是軟連接,若不加\,則改變軟連接文件的所屬用戶(組);若加上\,則改變真實文件的所屬用戶(組)。-R表示作用到目錄文件及全部子文件。

複製php.ini

安裝完PHP後,可以在命令行中輸入# php -i | grep ini
查看php.ini應當存放的路徑,然後將源代碼安裝包中的php.ini-development文件拷貝一份,如下:

[root@sy-pc lib]# php -i | grep ini 
Configuration File (php.ini) Path => /application/php-7.2.1/lib
Loaded Configuration File => /application/php-7.2.1/lib/php.ini

那麼我應該將拷貝的文件放入到/application/php-7.2.1/lib/php.ini。
cp /home/sy/Downloads/php-7.2.1/php.ini-development /application/php-7.2.1/lib/php.ini
開發環境,拷貝php.ini-development文件;
生產環境,考本php.ini-production文件。

有關錯誤的配置:

  • error_log 錯誤日誌的生成目錄(~/etc/php-fpm.conf)
  • error_reporting 生產環境錯誤級別應全開(~/lib/php.ini)
  • display_errors 在頁面上不顯示錯誤(~/lib/php.ini)
  • log_errors 開啓錯誤日誌(~/lib/php.ini)

設置上傳文件大小、時區

# vim /application/php/lib/php.ini

post_max_size = 20M
upload_max_filesize = 20M
date.timezone = Asia/Shanghai

命令行配置文件:

# cp php.ini php-cli.ini
若沒有獨立的命令行配置文件,則命令行加載php.ini文件中的配置。

php-fpm慢日誌

vim PHP安裝目錄/etc/php-fpm.d/www.conf

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; Depth of slow log stack trace.
; Default Value: 20
;request_slowlog_trace_depth = 20

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
  • slowlog 設置慢查詢日誌的生成目錄
  • request_slowlog_timeout 設置慢查詢的標準時間(打開此配置就相當於開啓了慢查詢日誌),配置以秒爲單位,一般設置3s。

PHP進程號和錯誤日誌

  配置進程文件、錯誤日誌
# vim /application/php/etc/php-fpm.conf

pid = run/php-fpm.pid
error_log=/wwwroot/logs/php_error_log/php7.2.1/php-fpm.log

PHP進程的屬主屬組和監聽端口

# vim /application/php/etc/php-fpm.d/www.conf

user = www
group = www
listen = 127.0.0.1:9000

php加入到環境變量中:

# vim /etc/profile

#手工加入
PATH=/application/php/bin:$PATH

保存退出後,
重新引入
# source /etc/profile

複製php-fpm配置文件

cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf
(因爲php-fpm.conf文件的最後一句include=/application/php-7.2.1/etc/php-fpm.d/*.conf ,所以要執行下一句)
cp /application/php/etc/php-fpm.d/www.conf.default /application/php/etc/php-fpm.d/www.conf

編輯www.conf文件,如果註釋了下面兩行user 和 group,那麼以root身份啓動/application/php/sbin/php-fpm會導致失敗。
在這裏插入圖片描述

啓動fpm

/application/php/sbin/php-fpm

/application/php/bin/php-cgi -b 127.0.0.1:9000 -c /application/php/etc/php.ini

/application/php/sbin/php-fpm -c /application/php/lib/php.ini -y /application/php/etc/php-fpm.conf

測試php-fpm配置
/application/php/sbin/php-fpm -t

/application/php/sbin/php-fpm -c /application/php/lib/php.ini -y /application/php/etc/php-fpm.conf -t

根據端口號查看進程:
# lsof -i :9000
殺死進程
kill -o 進程ID
killall php-fpm #殺死php-fpm進程

kill `lsof -i:9000|grep php|head -1|awk '{print $2}'`
kill `netstat -lntup | grep php | grep -v grep | awk '{print $7}' | awk -F / '{print $1}'`
kill `ps -ef | grep php | grep -v grep | head -1 | awk '{print $2}'`

設置php-fpm.pid的文件路徑

vim /application/php/etc/php-fpm.conf
;pid = run/php-fpm.pid
改成 pid = run/php-fpm.pid
則php-fpm.pid文件在php的安裝目錄的下的var/run/目錄下,
此次安裝後的目錄是/application/php/var/run/php-fpm。

設置php-fpm.log的文件路徑

vim /application/php/etc/php-fpm.conf
;error_log = log/php-fpm.log
改成 error_log=/wwwroot/logs/php_error_log/php版本號/php-fpm.log

平滑重啓php-fpm

kill -USR2 `cat /application/php/var/run/php-fpm.pid`

參考:http://blog.csdn.net/u010098331/article/details/50737322

++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++

安裝PHP擴展

在線安裝擴展

命令如:
/application/php/bin/pecl install pthreads

編譯安裝

gd庫
# yum install freetype* libwebp* libjpeg* libpng* libXpm*
但是phpinfo()的結果是
Linux版默認:
在這裏插入圖片描述

Windows版完整如下:
在這裏插入圖片描述

freetype
https://www.freetype.org/
++++++++++++++++++++++++++++++++++++++++++
https://fossies.org/linux/misc/jpegsrc.v9b.tar.gz
jpegsrc.v9b.tab.gz

# tar -zxvf jpegsrc.v9b.tab.gz
# cd jpeg-9b
# ./configure --prefix=/home/sy/local/jpegsrc
# make && make install

# yum install freetype* libwebp* libjpeg* libpng* libXpm*
進入php源碼目錄的gd擴展目錄

# /application/php/bin/phpize
# ./configure --with-php-config=/application/php/bin/php-config  --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local    
# make && make install  

如果以前編譯過,建議 make clean && make && make install
php.ini文件增加一句話extension=gd
++++++++++++++++++++++++++++++++++++++++++

安裝php-redis擴展

下載解壓 https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
下載地址 http://pecl.php.net/package/redis
但是因爲本機安裝了php7,所以必須要下載php7redis包
https://github.com/phpredis/phpredis/archive/php7.zip

# cd /home/sy/Downloads
# wget https://github.com/phpredis/phpredis/archive/php7.zip
# unzip phpredis-php7.zip
# cd phpredis-php

編譯安裝:先用phpize編譯生成configure等文件

[root@sy-pc phpredis-2.2.4]# /application/php/bin/phpize  
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@sy-pc phpredis-php7]# ./configure --with-php-config=/application/php/bin/php-config  
# make  
[root@sy-pc phpredis-php7]# make install  
make && make install  
Installing shared extensions:     /application/php-7.2.1/lib/php/extensions/debug-zts-20170718/

根據php.ini實際所在的路徑,修改php.ini文件,加一句話:

extension=redis

安裝memcache擴展

安裝libmemcached
下載地址:https://launchpad.net/libmemcached/+download
如libmemcached-1.0.18.tar.gz

# tar -zxvf libmemcached-1.0.18.tar.gz
# cd libmemcached-1.0.18
# ./configure --prefix=/home/sy/local/libmemcached1.0.18
# make && make install

下載memcached擴展包並安裝
https://github.com/php-memcached-dev/php-memcached
如php-memcached-master.zip

# unzip php-memcached-master.zip
# cd php-memcached-master
# /application/php/bin/phpize
# ./configure -with-php-config=/application/php/bin/php-config -with-libmemcached-dir=/home/sy/local/libmemcached1.0.18 -enable-memcached --disable-memcached-sasl  

注意:

  1. 如果是yum安裝libmemcached,則-with-libmemcached-dir=/usr
  2. 如果沒有–disable-memcached-sasl ,則會出現
checking sasl/sasl.h usability... no
checking sasl/sasl.h presence... no
checking for sasl/sasl.h... no
configure: error: no, sasl.h is not available. Run configure with --disable-memcached-sasl to disable this check

安裝

# make && make install
Installing shared extensions:     /application/php-7.2.1/lib/php/extensions/debug-zts-20170718/

修改php.ini文件,添加一句,或者用完整的一句。建議用下面的第一句。

extension=memcached.so
extension=/application/php-7.2.1/lib/php/extensions/debug-zts-20170718/memcached.so

安裝memcache擴展
下載memcache源代碼 http://pecl.php.net/package/memcache (太老的版本,不適合php7)
如memcache-3.0.8.tgz

# tar -zxvf memcache-3.0.8
# cd memcache-3.0.8
# /application/php/bin/phpize
# ./configure -with-php-config=/application/php/bin/php-config 
# make 

提示錯誤

In file included from /home/sy/Downloads/memcache-3.0.8/php_memcache.h:34:0,
                 from /home/sy/Downloads/memcache-3.0.8/memcache.c:30:
/home/sy/Downloads/memcache-3.0.8/memcache_pool.h:45:47: fatal error: ext/standard/php_smart_str_public.h: No such file or directory
 #include "ext/standard/php_smart_str_public.h"
                                               ^
compilation terminated.
make: *** [memcache.lo] Error 1

參看網站http://www.lnmp.cn/install-memcache-and-memcached-extends-under-php7.html
下載https://github.com/websupport-sk/pecl-memcache
如pecl-memcache-NON_BLOCKING_IO_php7.zip

# unzip pecl-memcache-NON_BLOCKING_IO_php7.zip
# cd pecl-memcache-NON_BLOCKING_IO_php7
# /application/php/bin/phpize  
# ./configure -with-php-config=/application/php/bin/php-config  
# make && make install
extension=memcached

++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++
爲了使用cURL函數,安裝libcurl庫,造成的混淆

# yum install libcurl* -y
# whereis libcurl
libcurl: /usr/lib64/libcurl.so /usr/share/man/man3/libcurl.3.gz

在php.ini中添加extension=/usr/lib64/libcurl.so,但是啓動php-fpm是提示

NOTICE: PHP message: PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'curl.so' in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Invalid library (maybe not a PHP library) 'curl.so' in <b>Unknown</b> on line <b>0</b><br />

後來,進入php7.1.6的源代碼安裝包

# cd ext
# cd curl
# /application/php-7.1.6/bin/phpize 
# ./configure --with-php-config=/application/php-7.1.6/bin/php-config  
# make && make install
Installing shared extensions:     /application/php-7.1.6/lib/php/extensions/no-debug-non-zts-20160303/

編輯了php.ini文件

extension=curl.so

但是啓動php-fpm仍然報錯。和上面的一樣。
然後修改php.ini文件爲
extension=/application/php-7.1.6/lib/php/extensions/no-debug-non-zts-20160303/curl.so
或者
extension_dir=/application/php-7.1.6/lib/php/extensions/no-debug-non-zts-20160303/ extension=curl.so

安裝mcrypt擴展

編譯後提示

# ./configure --with-php-config=/application/php/bin/php-config  
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

源文件的庫太老了,所以沒有繼續安裝
解決方式參考:http://www.zjmainstay.cn/php-mcrypt
http://www.cnblogs.com/huangzhen/archive/2012/09/12/2681861.html

下載libmcrypt https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
下載mhash https://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
下載 mcrypt http://pecl.php.net/package/mcrypt 選擇吧

或者懶人安裝方式:
yum install libmcrypt libmcrypt-devel mcrypt mhash

#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install 說明:libmcript默認安裝在/usr/local
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
# tar -zxvf mcrypt-1.0.1.tgz
# cd mcrypt-1.0.1
# /application/php/bin/phpize  
# ./configure -with-php-config=/application/php/bin/php-config  
# make && make install
extension=mcrytp
zend_extension=xdebug

安裝imagick擴展

#yum install ImageMagick ImageMagick-c++ ImageMagick-c++-devel ImageMagick-devel ImageMagick-doc ImageMagick-perl
下載imagick擴展:http://pecl.php.net/package/imagick 如imagick-3.4.3.tgz

# tar -zxvf imagick-3.4.3.tgz
# cd imagick-3.4.3/
# /application/php/bin/phpize  
# ./configure
# make && make install

php.ini文件增加一句話extension=imagick.so

++++++++++++++++++++++++++++++++++++++++++
如安裝zlib擴展的時候出現Cannot find config.m4. Make sure that you run ‘/home/sy/local/php7.1.6/bin/phpize’ in the top level source directory of the module的解決方法 :
進入php源碼包目錄:cd /home/sy/local/php7.1.6/ext/zlib
執行命令: cp ./config0.m4 ./config.m4 即可

++++++++++++++++++++++++++++++++++++++++++
PHP 7.3.0安裝zlib擴展失敗:
錯誤:checking for libzip… configure: error: system libzip must be upgraded to version >= 0.11
方案:https://www.uedbox.com/centos7-ziparchive-libzip/

錯誤:configure.ac:3: error: Autoconf version 2.68 or higher is required
方案:https://blog.csdn.net/yongcto/article/details/24791885

++++++++++++++++++++++++++++++++++++++++++
安裝enchant擴展的錯誤與解決
./configure編譯後提示
configure: error: Cannot find enchant
執行命令: yum -y install enchant-devel

++++++++++++++++++++++++++++++++++++++++++
安裝gmp擴展
./configure編譯後提示
configure: error: Unable to locate gmp.h
執行:
yum -y install gmp*
yum -y install gmp-devel

++++++++++++++++++++++++++++++++++++++++++
安裝imap擴展–然並卵
checking for IMAP support… yes, shared
checking for IMAP Kerberos support… no
checking for IMAP SSL support… no
checking for utf8_mime2text signature… new
checking for U8T_DECOMPOSE…
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
執行:# yum install libc* --skip-broken

++++++++++++++++++++++++++++++++++++++++++
安裝interbase擴展:失敗
編譯後提示
configure: error: libfbclient, libgds or libib_util not found! Check config.log for more information.
執行;
yum install libf*

++++++++++++++++++++++++++++++++++++++++++
安裝ldap擴展:
編譯後提示

./configure --with-php-config=/application/php/bin/php-config

configure: error: Cannot find ldap.h
執行:# yum -y install openldap-devel
編譯後提示

# ./configure --with-php-config=/application/php/bin/php-config
configure: error: Cannot find ldap libraries in /usr/lib.

分析原因:
可能原因是安裝了64位的系統,在/usr/lib64目錄下,而在/usr/lib目錄下沒有。
解決方式一:強制複製一次:
# cp -frp /usr/lib64/libdap* /usr/lib/
解決方式二:編譯時指定libraries所在目錄(推薦)
# ./configure --with-php-config=/application/php/bin/php-config --with-libdir=lib64

++++++++++++++++++++++++++++++++++++++++++

安裝mcrypt擴展

編譯後提示

# ./configure --with-php-config=/application/php/bin/php-config  
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

源文件的庫太老了,所以沒有繼續安裝
解決方式參考:http://www.zjmainstay.cn/php-mcrypt
http://www.cnblogs.com/huangzhen/archive/2012/09/12/2681861.html

或者懶人安裝方式:
yum install libmcrypt libmcrypt-devel mcrypt mhash

++++++++++++++++++++++++++++++++++++++++++
安裝oci8擴展
編譯後提示
checking checking if we’re on a 64-bit platform… yes
configure: WARNING: OCI8 extension: ORACLE_HOME is not set, looking for default Oracle Instant Client instead
checking Oracle Instant Client directory… configure: error: Oracle Instant Client directory /usr/lib/oracle/…/client64/lib libraries not found. Try --with-oci8=instantclient,DIR
沒有繼續安裝

++++++++++++++++++++++++++++++++++++++++++
安裝odbc擴展
編譯後提示
checking for Adabas support… cp: cannot stat ‘/usr/local/lib/odbclib.a’: No such file or directory
configure: error: ODBC header file ‘/usr/local/incl/sqlext.h’ not found!
解決方式:
yum install unixODBC-devel
但是源文件太老,沒有繼續安裝

++++++++++++++++++++++++++++++++++++++++++

安裝opcache擴展

cd /home/sy/Downloads/php-7.1.6/ext/opcache
編譯
/application/php/bin/phpize
./configure --with-php-config=/application/php/bin/php-config
安裝
make && make install
修改php.ini文件
vim /application/php/lib/php.ini
zend_extension=opcache.so

++++++++++++++++++++++++++++++++++++++++++

安裝pgsql擴展

提示
checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
執行
yum install postgresql-devel

++++++++++++++++++++++++++++++++++++++++++
安裝pspell擴展
提示
configure: error: Cannot find pspell
執行:
yum install aspell-devel

++++++++++++++++++++++++++++++++++++++++++
安裝recode擴展
提示:
configure: error: Can not find recode.h anywhere under yes /usr/local /usr /opt.
執行
yum install recode-devel

++++++++++++++++++++++++++++++++++++++++++
安裝tidy擴展
提示
checking for TIDY support… yes, shared
configure: error: Cannot find libtidy
擴展太老

++++++++++++++++++++++++++++++++++++++++++

Xdebug擴展

Note:
如果需要將 » Xdebug 擴展和 OPcache 一起使用,必須在 Xdebug 擴展之前加載 OPcache 擴展。
下載地址:https://xdebug.org/download.php

# tar -zxvf xdebug-2.5.5.tgz
# cd  xdebug-2.5.5
[root@sy-pc xdebug-2.5.5]# /application/php/bin/phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@sy-pc xdebug-2.5.5]# ./configure --with-php-config=/application/php/bin/php-config

然後修改php.ini文件,添加擴展語句

# vim /application/php/lib/php.ini
zend_extension=xdebug.so

安裝apcu擴展

安裝id3擴展
下載:http://pecl.php.net/package/id3

# tar -zxvf id3-0.2.tgz
# cd id3-0.2
# /application/php/bin/phpize
# ./configure --with-php-config=/application/php/bin/php-config
# make

修改id3.c文件
如196行 function_entry 改爲 zend_function
如刪除 ENFORCE_SAFE_MODE undeclared 則刪除 ENFORCE_SAFE_MODE

# make && make install

編輯php.ini文件

安裝pdo_odbc擴展

checking for PDO includes... checking for PDO includes... /home/sy/local/php7.2.1/include/php/ext
checking for selected PDO ODBC flavour... configure: error: Unknown ODBC flavour /usr
			  include and lib dirs are looked for under 'dir'.

			  'flavour' can be one of:  ibm-db2, iODBC, unixODBC, generic
			  If ',dir' part is omitted, default for the flavour
			  you have selected will be used. e.g.:

			    --with-pdo-odbc=unixODBC

			  will check for unixODBC under /usr/local. You may attempt
			  to use an otherwise unsupported driver using the "generic"
			  flavour.  The syntax for generic ODBC support is:

			    --with-pdo-odbc=generic,dir,libname,ldflags,cflags

			  When built as 'shared' the extension filename is always pdo_odbc.so

yum -y install unixODBC-*
進入PHP源文件ext/pdo_odbc目錄,
/home/sy/local/php7.1.6/bin/phpize

./configure --with-php-config=/application/php/bin/php-config --with-pdo-odbc=unixODBC,/usr

make && make install

安裝sodium擴展

參考:https://blog.csdn.net/hnhuangyiyang/article/details/50421657
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz

其他編譯錯誤

如安裝 ldap擴展
configure: error: Cannot find ldap libraries in /usr/lib
解決方案:
cp -frp /usr/lib64/libldap* /usr/lib/

使用Redis存儲session

編輯php.ini文件。如果爲Redis已經添加了auth權限(requirpass),則session.save_path的值需要加GET參數。

session.save_handler = Redis

session.save_path =  "tcp://192.168.55.170:6379?persistent=1&database=10&auth=Redis密碼"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章