(–enable-maintainer-zts 线程安全模式)
(较少的配置)注意:--enable-fpm
./configure --prefix=/home/sy/local/php7.1.6 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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=/home/sy/local/php7.1.6 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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=/home/sy/local/php7.1.6 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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=/home/sy/local/php7.1.6 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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=/home/sy/local/php7 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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
注意:--enable-fpm --with-fpm-acl --enable-maintainer-zts --disable-inline-optimization --disable-zend-signals --with-gnu-ld
./configure --prefix=/home/sy/local/php7.1.8 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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
注意:--enable-maintainer-zts --with-tsrm-pthreads
./configure --prefix=/home/sy/local/php7.2.1 --enable-fpm --with-fpm-user=sy --with-fpm-group=sy --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
编译时的错误解决方案:http://www.javashuo.com/article/p-oiibfwxv-d.html
# make && make install
安装报错:
Wrote PEAR system config file at: /home/sy/local/php7.2.1/etc/pear.conf
You may want to add: /home/sy/local/php7.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 /home/sy/local/php7.2.1/bin/phar
cp: cannot stat ‘phar.phar’: No such file or directory
make: *** [install-pharcmd] Error 1
安装完PHP后,可以在命令行中输入# php -i | grep ini
查看php.ini应当存放的路径,然后将源代码安装包中的php.ini-development文件拷贝一份,如下:
[[email protected] lib]# php -i | grep ini Configuration File (php.ini) Path => /home/sy/local/php7.2.1/lib Loaded Configuration File => /home/sy/local/php7.2.1/lib/php.ini
那么我应该将拷贝的文件放入到/home/sy/local/php7.2.1/lib/php.ini。
cp /home/sy/Downloads/php-7.2.1/php.ini-development /home/sy/local/php7.2.1/lib/php.ini
# vim /home/sy/local/php7.2.1/lib/php.ini
post_max_size = 20M upload_max_filesize = 20M date.timezone = Asia/Shanghai
# cp php.ini php-cli.ini
配置进程文件、错误日志
# vim /home/sy/local/php7.2.1/etc/php-fpm.conf
pid = run/php-fpm.pid error_log=/wwwroot/logs/php_error_log/php7.2.1/php-fpm.log
# vim /home/sy/local/php7.2.1/etc/php-fpm.d/www.conf
user = sy group = sy listen = 127.0.0.1:9000
# vim /etc/profile
#手工加入 PATH=/home/sy/local/php7.2.1/bin:$PATH
保存退出后,
重新引入
# source /etc/profile
cp /home/sy/local/php7.2.1/etc/php-fpm.conf.default /home/sy/local/php7.2.1/etc/php-fpm.conf
(因为php-fpm.conf文件的最后一句include=/home/sy/local/php7.2.1/etc/php-fpm.d/*.conf ,所以要执行下一句)
cp /home/sy/local/php7.2.1/etc/php-fpm.d/www.conf.default /home/sy/local/php7.2.1/etc/php-fpm.d/www.conf
/home/sy/local/php7.2.1/sbin/php-fpm
/home/sy/local/php7.2.1/bin /php-cgi -b 127.0.0.1:9000 -c /home/sy/local/php7.2.1/etc/php.ini
根据端口号查看进程:
# lsof -i :9000
杀死进程
kill -o 进程ID
killall php-fpm
#杀死php-fpm进程
vim /home/sy/local/php5.6.32/etc/php-fpm.conf
将 ;pid = run/php-fpm.pid
改成 pid = run/php-fpm.pid
则php-fpm.pid文件在php的安装目录的下的var/run/目录下,
此次安装后的目录是/home/sy/local/php5.6.32/var/run/php-fpm。
vim /home/sy/local/php5.6.32/etc/php-fpm.conf
将 ;error_log = log/php-fpm.log
改成 error_log=/wwwroot/logs/php_error_log/php5.6.32/php-fpm.log
kill -USR2 `cat /home/sy/local/php5.6.32/var/run/php-fpm.pid`
参考:http://blog.csdn.net/u010098331/article/details/50737322
++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++
命令如:
/home/sy/local/php7.1.6/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扩展目录
# /home/sy/local/php7.1.6/bin/phpize # ./configure --with-php-config=/home/sy/local/php7.1.6/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
++++++++++++++++++++++++++++++++++++++++++
下载解压 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等文件
[[email protected] phpredis-2.2.4]# /home/sy/local/php7.2.1/bin/phpize Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303 [[email protected] phpredis-php7]# ./configure --with-php-config=/home/sy/local/php7.2.1/bin/php-config # make [[email protected] phpredis-php7]# make install make && make install Installing shared extensions: /home/sy/local/php7.2.1/lib/php/extensions/debug-zts-20170718/
根据php.ini实际所在的路径,修改php.ini文件,加一句话:
extension=redis
安装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 # /home/sy/local/php7.2.1/bin/phpize # ./configure -with-php-config=/home/sy/local/php7.2.1/bin/php-config -with-libmemcached-dir=/home/sy/local/libmemcached1.0.18 -enable-memcached --disable-memcached-sasl
如果没有–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: /home/sy/local/php7.2.1/lib/php/extensions/debug-zts-20170718/
修改php.ini文件,添加一句,或者用完整的一句
extension=memcached.so extension=/home/sy/local/php7.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 # /home/sy/local/php7.1.6/bin/phpize # ./configure -with-php-config=/home/sy/local/php7.1.6/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 # /home/sy/local/php7.2.1/bin/phpize # ./configure -with-php-config=/home/sy/local/php7.2.1/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 # /home/sy/local/php7.1.6/bin/phpize # ./configure --with-php-config=/home/sy/local/php7.1.6/bin/php-config # make && make install Installing shared extensions: /home/sy/local/php7.1.6/lib/php/extensions/no-debug-non-zts-20160303/
编辑了php.ini文件
extension=curl.so
但是启动php-fpm仍然报错。和上面的一样。
然后修改php.ini文件为
extension=/home/sy/local/php7.1.6/lib/php/extensions/no-debug-non-zts-20160303/curl.so
或者
extension_dir=/home/sy/local/php7.1.6/lib/php/extensions/no-debug-non-zts-20160303/ extension=curl.so
编译后提示
# ./configure --with-php-config=/home/sy/local/php7.2.1/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
#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 # /home/sy/local/php7.2.1/bin/phpize # ./configure -with-php-config=/home/sy/local/php7.2.1/bin/php-config # make && make install
extension=mcrytp zend_extension=xdebug
#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/ # /home/sy/local/php7.1.6/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 即可
++++++++++++++++++++++++++++++++++++++++++
安装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: error: Cannot find ldap.h
执行:# yum -y install openldap-devel
编译后提示
# ./configure --with-php-config=/home/sy/local/php7.1.6/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=/home/sy/local/php7.1.6/bin/php-config --with-libdir=lib64
++++++++++++++++++++++++++++++++++++++++++
编译后提示
# ./configure --with-php-config=/home/sy/local/php7.1.6/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
但是源文件太老,没有继续安装
++++++++++++++++++++++++++++++++++++++++++
cd /home/sy/Downloads/php-7.1.6/ext/opcache
编译
/home/sy/local/php7.1.6/bin/phpize
./configure --with-php-config=/home/sy/local/php7.1.6/bin/php-config
安装
make && make install
修改php.ini文件
vim /home/sy/local/php7.1.6/lib/php.ini
zend_extension=opcache.so
++++++++++++++++++++++++++++++++++++++++++
提示
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
扩展太老
++++++++++++++++++++++++++++++++++++++++++
下载地址:https://xdebug.org/download.php
# tar -zxvf xdebug-2.5.5.tgz # cd xdebug-2.5.5 [[email protected] xdebug-2.5.5]# /home/sy/local/php7.1.6/bin/phpize Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303 [[email protected] xdebug-2.5.5]# ./configure --with-php-config=/home/sy/local/php7.1.6/bin/php-config
然后修改php.ini文件,添加扩展语句
# vim /home/sy/local/php7.1.6/lib/php.ini zend_extension=xdebug.so
安装id3扩展
下载:http://pecl.php.net/package/id3
# tar -zxvf id3-0.2.tgz # cd id3-0.2 # /home/sy/local/php7.1.6/bin/phpize # ./configure --with-php-config=/home/sy/local/php7.1.6/bin/php-config # make
修改id3.c文件
如196行 function_entry 改为 zend_function
如删除 ENFORCE_SAFE_MODE undeclared 则删除 ENFORCE_SAFE_MODE
# make && make install
编辑php.ini文件