WordPress微信支付/登录插件常见php库安装方法

2017-07-10 点击:1370

我们的插件对php环境有基本的要求,正常使用需要安装php curl组件,正常的网站环境,比如LNMP一健安装包,都包含了php curl组件,少数网站环境缺少php基础组件,需要手动安装。

#进入php源代码目录
[root@cqs local]#cd /home/cqs/source/php-7.0.1/
#进入ext扩展目录
[root@cqs php-7.0.1 ]#cd ext
[root@cqs ext ]#cd curl
[root@cqs curl ]#phpize #报错,没有这个命令或文件
Cannot find config.m4.
Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module
解决方案:http://blog.csdn.net/xinguan1267/article/details/6118187
[root@cqs local]# cd /home/cqs/source/php-7.0.1/ext/
[root@cqs ext]# ./ext_skel --extname=my_module
Creating directory my_module
Creating basic files: config.m4 .cvsignore my_module.c php_my_module.h CREDITS EXPERIMENTAL tests/001.phpt my_module.php [done].
 
To use your new extension, you will have to execute the following steps:
1.  $ cd ..
2.  $ vi ext/my_module/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-my_module
5.  $ make
6.  $ ./php -f ext/my_module/my_module.php
7.  $ vi ext/my_module/my_module.c
8.  $ make
执行了这个步骤以后你会看到这样的结果
Repeat steps 3-6 until you are satisfied with ext/my_module/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.
这样以后我们会在这个目录下生成一个目录叫my_module
进入这里面我们看看
[root@cqs ext]# cd my_module
[root@cqs my_module]# ls
acinclude.m4    build         config.h.in  config.nice    configure     CREDITS       install-sh  Makefile            Makefile.objects  modules       my_module.lo     run-tests.php
aclocal.m4      config.guess  config.log   config.
…………省略,注意最后的时候要去配置php.ini,增加对应的扩展 
extension= /usr/local/php/lib/php/extensions/no-debug-zts-20151012/my_module.so
 
#搞定之后我们执行以下代码
[root@cqs curl ]#/usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
 
[root@cqs curl]# ./configure --with-curl=/usr/local/curl-7.20.0/   
configure: error: Cannot find php-config. Please use --with-php-config=PATH
[root@cqs curl]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/curl-7.20.0/
[root@cqs curl]# make#由于之前折腾了几次,估计是有冲突的垃圾,一直报错
[root@cqs curl]# make clean #清除垃圾
[root@cqs curl]#./configure --with-php-config=/usr/local/php/bin/php-config --with-curl=/usr/local/curl-7.20.0/
[root@cqs curl]# make#这回妥妥的通过了
[root@cqs curl]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20151012/
[root@cqs curl]# cd  /usr/local/php/lib/php/extensions/no-debug-zts-20151012/
[root@cqs no-debug-zts-20151012]# ls
curl.so  my_module.so  opcache.so  zip.so
#看到了产生curl.so扩展了
接着修改对应的配置文档php.ini
增加
extension= /usr/local/php/lib/php/extensions/no-debug-zts-20151012/curl.so
# /usr/local/php/bin/php -m 如果看到有curl项表示成功。
[root@cqs my_module]# /usr/local/php/bin/php -m
[PHP Modules]
Core
ctype
curl
libxml
my_module
....
[Zend Modules]
#重启apache
[root@cqs my_module]# /usr/local/httpd-2.4.18/bin/apachectl restart
在浏览器打开info.php
说明成功安装curl扩展了,解决了对应的问题。
 
结论:如果想在已经安装的php扩展相关的软件包时,我们可以不用对Php进行重新配置,编辑和安装,我们可以利用phpize自定义扩展php的相关软件包。
 

 CentOS下安装php的mbstring扩展 

php的mbstring扩展如果没有安装会导致一些问题:

例1:登陆phpMyAdmin的时候会提示没字符串编码和字符串处理库 php_mbstring,有些程序中会
用到mb_substr函数没有php的mbstring扩展当这些程序运行的时候通常会提示“Fatal error: Call to
undefined function mb_substr()”。

例2:安装phpRedisAdmin页面访问为空白。

下面是安装步骤:
1.安装mbstring扩展

yum -y install php-mbstring
2.配置php.ini支持该扩展

vi /etc/php.ini
文件添加

extension=mbstring.so
3.重启httpd服务

service httpd restart
完成。


立即加【QQ:6347007】试用WordPress支付插件

相关产品

  • WordPress QQ/微博/微信/钉钉/手机登录插件
    WordPress QQ/微博/微信/钉钉/手机登录插件

  • WordPress WooCommerce微信支付插件红包版
    WordPress WooCommerce微信支付插件红包版

相关博客

  • Windows Server 2012 安装PHP环境用于WordPress微信直播