ubuntu源码安装php

环境:
ubuntu:20.4
php-7.4.22.tgz

如何安装,看Unix系统下的安装

php-8.0.9源码包解压缩,因为要安装mochat,安装wxwork_finance_sdk时报错(问题),说是intl冲突,因此排除掉

./configure --prefix=/usr/local/php-8.0.9/ --with-config-file-path=/usr/local/php-8.0.9/etc --with-config-file-scan-dir=/usr/local/php-8.0.9/etc/conf.d  --disable-intl

此时会有各种各样的报错(因为没有安装各种包嘛),一个一个解决吧
No package 'libxml-2.0' found ,解决: sudo apt install libxml2-dev
No package 'sqlite3' found,解决:sudo apt install libsqlite3-dev
最终结果为:
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

下面执行make和make install
make -j4


php安装扩展,内容如下:

安装扩展

PHP有两种可供安装的扩展:一种是PHP原生的但是默认没有安装的,另一种的第三方开发的扩展。

下面依次介绍两种扩展的安装方法:

安装之前我们需要一份和当前机器上相同版本的PHP源码

cd code
wget http://cn2.php.net/distributions/php-5.5.9.tar.bz2
tar xvjf php-5.5.9.tar.bz2
cd php-5.5.9

前往此处 下载相应的源码包。

在 /ext 目录下面可以看到所有PHP原生的扩展。

安装原生扩展

以 PHP-intl 为例,这是PHP国际化的扩展。

为了安装这个扩展我们需要先安装ICU 库

sudo apt-get install icu-devtools icu-doc libicu-dev libicu52 libicu52-dbg

ICU 安装成功之后进入/ext/intl 目录:

cd intl
phpize
./configure --enable-intl
make
sudo make install

下面解释一下上面的每个命令:

  • phpize : 是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块
  • ./configure --enable-intl: 配置编译环境,相当于告诉编译器编译PHP源码的时候加上intl这个扩展。
  • make: 将会把源码编译成 intl.so
  • make install : 将会把 intl.so 移动到当前安装的 PHP 的扩展目录。

接下来我们要做的就是在php.ini中启用这个扩展,这一步将会在最后给出示例。

安装第三方扩展

将以这个 扩展为例,这个扩展主要实现了PHP识别条形码的功能。

先安装必要的依赖

sudo apt-get install pkg-config
git clone https://github.com/mongodb/mongo-php-driver
cd mongo-php-driver
phpize
./configure
make
sudo make install

将会生成一个文件,将其拷贝到PHP的扩展目录下面。

启用扩展

在php.ini中启用扩展的方式有很多:

  1. 直接在php.ini文件中添加 extension=mongo.so,这是最简单直接的方法。
  2. 也可以单独建一个ini文件,然后在php.ini中包含这些文件就可以了。

下面介绍一下第二种方法:

cd `/etc/php5/mods-available`

这个目录里可以放新建的ini文件,然后执行

sudo touch mongo.ini
echo "extension=mongo.so" | sudo tee -a mongo.ini
sudo touch intl.ini
echo "extension=intl.so" | sudo tee -a intl.ini

上面的命令将会创建ini文件,并且写如相应的配置信息。

然后执行下面的命令启用扩展即可(需要安装 php5enmod 工具):

sudo php5enmod mongo
sudo php5enmod intl

如果未安装 php5enmod 工具,则需要手动配置:

ln -s /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/mongo.ini
ln -s /etc/php5/mods-available/intl.ini /etc/php5/cli/conf.d/intl.ini
ln -s /etc/php5/mods-available/mongo.ini /etc/php5/fpm/conf.d/mongo.ini
ln -s /etc/php5/mods-available/intl.ini /etc/php5/fpm/conf.d/intl.ini

最后在执行一下重启操作就可以了:

sudo service nginx restart
sudo service php5-fpm restart

以安装opcache为例,
cd ext/opcache
phpize
./configure --enable-opcache
make && sudo make install 
比较奇葩的是,我在/usr/local/php-8.0.9/etc/conf.d/opcache.ini中增加了如下内容:
extension=opcache.so
然后执行php -m | grep opcache之后,居然报错了:
PHP Warning:  PHP Startup: Invalid library (appears to be a Zend Extension, try loading using zend_extension=opcache.so from php.ini) in Unknown on line 0
Warning: PHP Startup: Invalid library (appears to be a Zend Extension, try loading using zend_extension=opcache.so from php.ini) in Unknown online 0

于是我将opcache.ini中的内容修改为
zend_extension=opcache.so
opcache.enable=1

然后再执行php -m ,就ok了。


安装zlib,进入ext/zlib,执行phpize,提示错误: Cannot find config.m4.
Make sure that you run '/usr/local/php-8.0.9/bin/phpize' in the top level source directory of the module
发现有一个文件叫config0.m4,将其重命名为config.m4
phpize
./configure --enable-zlib --with-zlib ,又报错了:No package 'zlib' found
执行sudo apt install zlib1g-dev 再执行./configure --enable-zlib --with-zlib,成功但出现警告:configure: WARNING: unrecognized options: --enable-zlib
去掉--enable-zlib,执行./configure   --with-zlib
make && sudo make install 
结果为:
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
配置zlib:
sudo vim /usr/local/php-8.0.9/etc/conf.d/zlib.ini
内容为:extension=zlib.so

xsl安装:
phpize
./configure --with-xsl --enable-xsl,报错,提示No package 'libxslt' found
sudo apt-get install libxslt1-dev
再次执行:./configure --with-xsl --enable-xsl
configure: WARNING: unrecognized options: --enable-xsl
再次执行:./configure --with-xsl && make &&sudo make install ,ok!
ls /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ | grep xsl
-rwxr-xr-x 1 root root 207K Aug 13 10:24 xsl.so
配置zlib:
sudo vim /usr/local/php-8.0.9/etc/conf.d/xsl.ini
内容为:extension=xsl.so

zip安装:
./configure --with-zip --enable-zip :
No package 'libzip' found
sudo apt-get install libzip-dev
./configure --with-zip --enable-zip:
configure: WARNING: unrecognized options: --enable-zip
./configure --with-zip  
make &&sudo make install :
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ 
配置zip:
sudo vim /usr/local/php-8.0.9/etc/conf.d/zip.ini
内容为:extension=zip.so

安装tidy:
php -m |grep tidy,显示无tidy,开始进行安装。
phpize
./configure --with-tidy --enable-tidy:
configure: error: Cannot find libtidy
sudo apt install libtidy-dev
./configure --with-tidy --enable-tidy:
configure: WARNING: unrecognized options: --enable-tidy
./configure --with-tidy && make && sudo make install
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/

ls /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/| grep tidy
-rwxr-xr-x 1 root root 288K Aug 13 10:32 tidy.so
配置tidy:
sudo vim /usr/local/php-8.0.9/etc/conf.d/tidy.ini
内容为:extension=tidy.so

安装sodium:
sudo apt   install libsodium-dev
./configure --with-sodium && make && sudo make install 
ls /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ | grep sodium
-rwxr-xr-x 1 root root 379K Aug 13 10:48 sodium.so
配置sodium:
sudo vim /usr/local/php-8.0.9/etc/conf.d/sodium.ini
内容为:extension=sodium.so

安装sockets:
./configure --with-sockets --enable-sockets
configure: WARNING: unrecognized options: --with-sockets
./configure  --enable-sockets
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files:          /usr/local/php-8.0.9/include/php/
配置sockets:
sudo vim /usr/local/php-8.0.9/etc/conf.d/sockets.ini
内容为:extension=sockets.so

安装soap:
./configure --with-soap --enable-soap
configure: WARNING: unrecognized options: --with-soap
./configure  --enable-soap

Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/

ls /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ | grep soap
-rwxr-xr-x 1 root root 2.2M Aug 13 10:54 soap.so
配置soap:
sudo vim /usr/local/php-8.0.9/etc/conf.d/soap.ini
内容为:extension=soap.so

安装snmp:
./configure --with-snmp --enable-snmp
sudo apt-get install libsnmp-dev
configure: WARNING: unrecognized options: --enable-snmp
./configure --with-snmp  
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
ls /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ | grep snmp
-rwxr-xr-x 1 root root 321K Aug 13 10:58 snmp.so
配置snmp:
sudo vim /usr/local/php-8.0.9/etc/conf.d/snmp.ini
内容为:extension=snmp.so

安装readline:
./configure --with-readline --enable-readline
No package 'libedit' found
sudo apt install libedit-dev
./configure --with-readline --enable-readline
configure: WARNING: unrecognized options: --enable-readline
./configure --with-readline 
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
配置readline:
sudo vim /usr/local/php-8.0.9/etc/conf.d/readline.ini
内容为:extension=readline.so

安装pspell:
./configure --with-pspell --enable-pspell
configure: error: Cannot find pspell
sudo apt install libpspell-dev
./configure --with-pspell --enable-pspell
configure: WARNING: unrecognized options: --enable-pspell
./configure --with-pspell && make && sudo make install 

Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
配置pspell:
sudo vim /usr/local/php-8.0.9/etc/conf.d/pspell.ini
内容为:extension=pspell.so

安装pgsql:
./configure --with-pgsql --enable-pgsql:
checking for pg_config... not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

sudo apt install libpq-dev
./configure --with-pgsql --enable-pgsql:
configure: WARNING: unrecognized options: --enable-pgsql
./configure --with-pgsql  
make && sudo make install
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
 配置pgsql:
sudo vim /usr/local/php-8.0.9/etc/conf.d/pgsql.ini
内容为:extension=pgsql.so

安装pdo_pgsql:
./configure --with-pdo-pgsql --enable-pdo-pgsql
configure: WARNING: unrecognized options: --enable-pdo-pgsql
./configure --with-pdo-pgsql && make && sudo make install
配置pdo_pgsql:
sudo vim /usr/local/php-8.0.9/etc/conf.d/pdo_pgsql.ini
内容为:extension=pdo_pgsql.so

安装pdo_mysql:
./configure --with-pdo-mysql --enable-pdo-mysql
configure: WARNING: unrecognized options: --enable-pdo-mysql
./configure --with-pdo-mysql && make && sudo make install
配置pdo_pgsql:
sudo vim /usr/local/php-8.0.9/etc/conf.d/pdo_pgsql.ini
内容为:extension=pdo_pgsql.so

安装openssl:
cp config0.m4 config.m4
./configure --with-openssl --enable-openssl
configure: WARNING: unrecognized options: --enable-openssl
./configure --with-openssl && make && sudo make install 
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
配置openssl:
sudo vim /usr/local/php-8.0.9/etc/conf.d/openssl.ini
内容为:extension=openssl.so

mysqlnd安装:有问题,未安装成功!!!!
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'mysqlnd.so'
cp config9.m4 config.m4
./configure --with-mysqlnd --enable-mysqlnd
configure: WARNING: unrecognized options: --with-mysqlnd

./configure --enable-mysqlnd && make && sudo make install
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files:          /usr/local/php-8.0.9/include/php/
配置mysqlnd:
sudo vim /usr/local/php-8.0.9/etc/conf.d/mysqlnd.ini
内容为:extension=mysqlnd.so

mysqlnd.so重新安装:
./configure --with-php-config=/usr/local/php-8.0.9/bin/php-config --enable-mysqlnd 


mysqli安装:
phpize && ./configure --with-mysqli --enable-mysqli
configure: WARNING: unrecognized options: --enable-mysqli
 ./configure --with-mysqli  
配置mysqli:
sudo vim /usr/local/php-8.0.9/etc/conf.d/mysqli.ini
内容为:extension=mysqli.so
但执行php -m时会报错,找不到mysqli.so
这儿发现的如何编译mysqli.so,主要是这个:
./configure --prefix=/usr/local/php/ext/mysqli --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mysql_config

我本机的mysql找不到mysql_config,看了这里发现需要安装 libmysqld-dev 和 libmysqlclient-dev 两个包,但我ubuntu下只有libmysqlclient-dev 这个包,于是我只安装了这个包: sudo apt-get install libmysqlclient-dev,不过已经能找到mysql_config了。
which mysql_config
/usr/bin/mysql_config
重新编译mysqli.so:
phpize
./configure --with-php-config=/usr/local/php-8.0.9/bin/php-config --with-mysqli=/usr/bin/mysql_config 
还是报错了

不得已使用了mariadb相关包:
sudo apt-get install libmariadbd-dev  libmariadb-dev
./configure --with-php-config=/usr/local/php-8.0.9/bin/php-config --with-mysqli=/usr/bin/mariadb_config --with-mysqli  


mbstring安装:
./configure --enable-mbstring --with-mbstring
No package 'oniguruma' found
sudo apt-get install libonig-dev
./configure --enable-mbstring --with-mbstring
configure: WARNING: unrecognized options: --with-mbstring
./configure --enable-mbstring  
配置mbstring:
sudo vim /usr/local/php-8.0.9/etc/conf.d/mbstring.ini
内容为:extension=mbstring.so

ldap安装:
./configure --with-ldap --enable-ldap
configure: error: Cannot find ldap.h
sudo apt-get install libldap2-dev
./configure --with-ldap 
配置ldap:
sudo vim /usr/local/php-8.0.9/etc/conf.d/ldap.ini
内容为:extension=ldap.so

gmp安装:
phpize
./configure --with-gmp
配置gmp:
sudo vim /usr/local/php-8.0.9/etc/conf.d/gmp.ini
内容为:extension=gmp.so

gettext安装:
phpize
./configure --with-gettext
make && sudo make install
配置gettext:
sudo vim /usr/local/php-8.0.9/etc/conf.d/gettext.ini
内容为:extension=gettext.so

imap安装-未成功:
./configure --with-imap --with-imap-ssl
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing
sudo apt-get install libc-client2007e-dev libkrb5-dev
./configure --with-imap --with-imap-ssl --with-kerberos
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/imap.so
配置imap:
sudo vim /usr/local/php-8.0.9/etc/conf.d/imap.ini
内容为:extension=imap.so

gd安装:
./configure --enable-gd
No package 'libpng' found
sudo apt-get install libpng-dev
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/gd.so
配置gd:
sudo vim /usr/local/php-8.0.9/etc/conf.d/gd.ini
内容为:extension=gd.so

ftp安装:
./configure --enable-ftp
make && sudo make install 
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ftp.so
配置ftp:
sudo vim /usr/local/php-8.0.9/etc/conf.d/ftp.ini
内容为:extension=ftp.so

ffi安装:
./configure --with-ffi && make && sudo make install 
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/ffi.so
配置ffi:
sudo vim /usr/local/php-8.0.9/etc/conf.d/ffi.ini
内容为:extension=ffi.so

exif安装:
./configure --enable-exif && make &&sudo make install 
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/exif.so
配置exif:
sudo vim /usr/local/php-8.0.9/etc/conf.d/exif.ini
内容为:extension=exif.so

enchant安装:
./configure --with-enchant
No package 'enchant' found

sudo apt install libenchant-dev
 make &&sudo make install 
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/enchant.so
配置enchant:
sudo vim /usr/local/php-8.0.9/etc/conf.d/enchant.ini
内容为:extension=enchant.so

dba安装:
 ./configure --enable-dba
 make &&sudo make install 
配置dba:
sudo vim /usr/local/php-8.0.9/etc/conf.d/dba.ini
内容为:extension=dba.so

curl安装
 ./configure --with-curl
 make &&sudo make install 
配置curl:
sudo vim /usr/local/php-8.0.9/etc/conf.d/curl.ini
内容为:extension=curl.so

calendar安装:
./configure --enable-calendar
 make &&sudo make install 
配置calendar:
sudo vim /usr/local/php-8.0.9/etc/conf.d/calendar.ini
内容为:extension=calendar.so

bz2安装:
 ./configure --with-bz2
sudo apt-get install libbz2-dev
 ./configure --with-bz2
make && sudo make install
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/bz2.so
配置bz2:
sudo vim /usr/local/php-8.0.9/etc/conf.d/bz2.ini
内容为:extension=bz2.so

bcmath安装
./configure --enable-bcmath
make && sudo make install
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/bcmath.so
配置bcmath:
sudo vim /usr/local/php-8.0.9/etc/conf.d/bcmath.ini
内容为:extension=bcmath.so


pdo安装:
./configure --enable-pdo
make && sudo make install
/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/pdo.so
配置pdo:
sudo vim /usr/local/php-8.0.9/etc/conf.d/pdo.ini
内容为:extension=pdo.so
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files:          /usr/local/php-8.0.9/include/php/
Installing PDO headers:           /usr/local/php-8.0.9/include/php/ext/pdo/

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'pdo.so' in Unknown on line 0
Warning: PHP Startup: Invalid library (maybe not a PHP library) 'pdo.so' in Unknown on line 0


simplexml安装:
./configure --enable-simplexml
配置simplexml:
sudo vim /usr/local/php-8.0.9/etc/conf.d/simplexml.ini
内容为:extension=simplexml.so
[ubuntu@VM-0-9-ubuntu:simplexml]$ php -m |grep xml
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'simplexml.so' in Unknown on line 0
Warning: PHP Startup: Invalid library (maybe not a PHP library) 'simplexml.so' in Unknown on line 0
后来使用 php --ri simplexml

SimpleXML

SimpleXML support => enabled
Schema support => enabled

原来simplexml已启用了

pdo_mysql安装:
./configure --with-pdo-mysql
配置pdo_mysql:
sudo vim /usr/local/php-8.0.9/etc/conf.d/pdo_mysql.ini
内容为:extension=pdo_mysql.so

php-redis安装:
wget https://pecl.php.net/get/redis-5.3.4.tgz
tar -xzf redis-5.3.4.tgz
phpize
./configure --enable-redis
make && sudo make install 
Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
配置redis:
sudo vim /usr/local/php-8.0.9/etc/conf.d/redis.ini
内容为:extension=redis.so


swoole安装:
wget https://pecl.php.net/get/swoole-4.7.0.tgz
tar -xzf swoole-4.7.0.tgz
./configure --enable-swoole
make && sudo make install 
PATH="$PATH:/sbin" ldconfig -n /home/ubuntu/data/soft/swoole-4.7.0/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /home/ubuntu/data/soft/swoole-4.7.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files:          /usr/local/php-8.0.9/include/php/

配置swoole:
sudo vim /usr/local/php-8.0.9/etc/conf.d/swoole.ini
内容为:
extension=swoole.so
swoole.use_shortname = off 

安装composer:

这里

curl -sS https://getcomposer.org/installer | php

sudo mv composer.phar /usr/local/bin/composer



wxwork_finance_sdk PHP 扩展

[ubuntu@VM-0-9-ubuntu:php7-wxwork-finance-sdk-master]$ 
cp ../sdk_20201116/C_sdk/libWeWorkFinanceSdk_C.so .
[ubuntu@VM-0-9-ubuntu:php7-wxwork-finance-sdk-master]$ 
cp ../sdk_20201116/C_sdk/WeWorkFinanceSdk_C.h .

phpize
./configure --with-php-config=/usr/local/php-8.0.9/bin/php-config  --with-wxwork-finance-sdk=/home/ubuntu/data/soft/sdk_20201116/C_sdk/
make && sudo make install 

结果如下:
Libraries have been installed in:
   /home/ubuntu/data/soft/php7-wxwork-finance-sdk-master/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/

/usr/local/php-8.0.9/lib/php/extensions/no-debug-non-zts-20200930/wxwork_finance_sdk.so

配置wxwork_finance_sdk:
sudo vim /usr/local/php-8.0.9/etc/conf.d/wxwork_finance_sdk.ini
内容为:
extension=wxwork_finance_sdk.so



现在编译php-7.4.22版本:
./configure --prefix=/usr/local/php-7.4.22 --with-config-file-path=/usr/local/php-7.4.22/etc --with-config-file-scan-dir=/usr/local/php-7.4.22/etc/conf.d  --disable-intl --enable-fpm  --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir  --with-freetype --with-jpeg --with-libxml-dir --enable-xml --enable-rpath --enable-shmop --enable-sysvsem   --enable-inline-optimization  --enable-mbregex --enable-pcntl  --with-mhash  --with-xmlrpc  --with-gettext --enable-fileinfo   --enable-opcache   --with-zlib --with-xsl --with-zip  --with-tidy --with-sodium --enable-sockets --enable-soap  --with-snmp    --with-readline  --with-pspell  --with-pgsql    --with-pdo-pgsql    --with-openssl --enable-mbstring   --with-ldap  --with-gmp --enable-gd  --enable-ftp  --with-ffi --enable-exif  --with-enchant --enable-dba  --with-curl --enable-calendar --with-bz2  --enable-bcmath  

安装缺少的软件(缺啥补啥吧,软件包版本可能会有变化)
sudo apt install libxml2-dev libxml2-utils libxml2 pkg-config libssl-dev libsqlite3-dev zlib1g-dev libbz2-dev libcurl4 libcurl4-openssl-dev libenchant-dev libpng-dev libjpeg-dev libfreetype-dev libgmp-dev  libldap2-dev libonig-dev libpq-dev  libpspell-dev libreadline-dev libsnmp-dev libsodium-dev   libtidy-dev libxslt1-dev libzip-dev      

configure: WARNING: unrecognized options: --with-libxml-dir

make -j4 && sudo make install 



php-redis安装:
wget https://pecl.php.net/get/redis-5.3.4.tgz
tar -xzf redis-5.3.4.tgz
phpize
./configure --enable-redis
make && sudo make install 
Installing shared extensions:     /usr/local/php-7.4.22/lib/php/extensions/no-debug-non-zts-20190902/
配置redis:
sudo vim /usr/local/php-7.4.22/etc/conf.d/redis.ini
内容为:extension=redis.so


swoole安装:
wget https://pecl.php.net/get/swoole-4.7.0.tgz
tar -xzf swoole-4.7.0.tgz
./configure --enable-swoole
make && sudo make install 
PATH="$PATH:/sbin" ldconfig -n /home/ubuntu/data/soft/swoole-4.7.0/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /home/ubuntu/data/soft/swoole-4.7.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php-7.4.22/lib/php/extensions/no-debug-non-zts-20190902/
Installing header files:          /usr/local/php-7.4.22/include/php/

配置swoole:
sudo vim /usr/local/php-7.4.22/etc/conf.d/swoole.ini
内容为:
extension=swoole.so
swoole.use_shortname = off 

安装composer:

这里

curl -sS https://getcomposer.org/installer | php

sudo mv composer.phar /usr/local/bin/composer



wxwork_finance_sdk PHP 扩展

[ubuntu@VM-0-9-ubuntu:php7-wxwork-finance-sdk-master]$ 
cp ../sdk_20201116/C_sdk/libWeWorkFinanceSdk_C.so .
[ubuntu@VM-0-9-ubuntu:php7-wxwork-finance-sdk-master]$ 
cp ../sdk_20201116/C_sdk/WeWorkFinanceSdk_C.h .

phpize
./configure --with-php-config=/usr/local/php-7.4.22/bin/php-config  --with-wxwork-finance-sdk=/home/ubuntu/data/soft/sdk_20201116/C_sdk/
make && sudo make install 

结果如下:
Libraries have been installed in:
   /home/ubuntu/data/soft/wx-sdk/php7-wxwork-finance-sdk-master/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php-7.4.22/lib/php/extensions/no-debug-non-zts-20190902/



配置wxwork_finance_sdk:
sudo vim /usr/local/php-7.4.22/etc/conf.d/wxwork_finance_sdk.ini
内容为:
extension=wxwork_finance_sdk.so