zoukankan      html  css  js  c++  java
  • PHP5不重新编译,如何安装自带的未安装过的扩展,如soap扩展?

    在虚拟机的CentOS5.5中,一键安装了PHP运行环境,但发现并没有 soap 扩展,而近期项目用需要用到 webservice。

    上述的一键安装(lamp0.4),其实是源码编译安装,PHP配置文件的路径为 /etc/php.ini ,安装后,遗留的文件目录为 “/home/jianbao/2/lamp0.4”,里面的文件列表为:

    [root@localhost lamp0.4]# ll
    总计 59296
    -rw-r--r-- 1 root    root      982243 2012-05-23 apr-1.4.6.tar.gz
    -rw-r--r-- 1 root    root      774770 2012-05-23 apr-util-1.4.1.tar.gz
    drwxrwxr-x 2 jianbao jianbao     4096 2012-05-29 conf
    -rw-r--r-- 1 root    root     5616185 2012-05-23 httpd-2.4.2.tar.gz
    -rwxrwxr-x 1 jianbao jianbao    25116 2012-06-28 lamp.sh
    -rw-r--r-- 1 root    root     4984397 2012-01-21 libiconv-1.14.tar.gz
    -rw-r--r-- 1 root    root     1335178 2012-03-26 libmcrypt-2.5.8.tar.gz
    -rw-r--r-- 1 root    root      471915 2012-03-26 mcrypt-2.6.8.tar.gz
    -rw-r--r-- 1 root    root      931437 2012-03-26 mhash-0.9.9.9.tar.gz
    -rw-r--r-- 1 root    root    24518874 2012-05-10 mysql-5.5.24.tar.gz
    -rw-r--r-- 1 root    root    14913792 2012-05-10 php-5.3.13.tar.gz
    -rw-r--r-- 1 root    root     5944741 2012-05-10 phpMyAdmin-3.5.1-all-languages.tar.gz
    -rwxrwxr-x 1 jianbao jianbao     1792 2012-05-29 pureftpd.sh
    drwxr-xr-x 2 root    root        4096 06-09 21:36 untar
    -rwxrwxr-x 1 jianbao jianbao     1563 2012-02-14 xcache.sh
    -rwxrwxr-x 1 jianbao jianbao     2720 2012-06-15 zend.sh

    我选择的PHP版本为上述的 php-5.3.13.tar.gz,现在需要做的事情是:

    1、把 “php-5.3.13.tar.gz”源码压缩包拷贝的另外一个目录,如 “/home/jianbao/1”,并解压

    2、切换到解压后的 soap 源码目录:

    cd  /home/jianbao/1/php-5.3.13/ext/soap

    3、运行 phpize 命令:

    [jianbao@localhost soap]$ /usr/local/php/bin/phpize
    Configuring for:
    PHP Api Version:         20090626
    Zend Module Api No:      20090626
    Zend Extension Api No:   220090626

    这时,会在当前目录生成 configure 等文件。

    4、运行 configure 命令:

    [jianbao@localhost soap]$ ./configure --with-php-config=/usr/local/php/bin/php-config --enable-soap
    checking for egrep... grep -E
    checking for a sed that does not truncate output... /bin/sed
    checking for cc... cc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    ...
    ...
    ...
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... yes
    checking whether to build static libraries... no
    
    creating libtool
    appending configuration tag "CXX" to libtool
    configure: creating ./config.status
    config.status: creating config.h

    5、运行 make 命令:

    [jianbao@localhost soap]$ make
    /bin/sh /home/jianbao/1/php-5.3.13/ext/soap/libtool --mode=compile cc  -I. -I/home/jianbao/1/php-5.3.13/ext/soap -DPHP_ATOM_INC ......

    6、运行 make  install 命令:

    注意,会出现权限问题,临时切换到 root 用户即可。

    [jianbao@localhost soap]$ su
    口令:
    [root@localhost soap]# make install
    Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
    [root@localhost soap]# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
    总计 832
    -rwxr-xr-x 1 root root 840501 06-10 01:09 soap.so
    [root@localhost soap]#

    安装好之后会提示 soap.so 文件的保存路径

    7、修改 /etc/php.ini 文件:

    找到 extension_dir="./",默认是注释掉的,

    修改为 extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/" 

    并在此行后增加如下配置:

    extension=soap.so

    然后保存。

    8、重启 Apache:

    [root@localhost jianbao]# /etc/init.d/httpd restart
    停止 httpd:                                               [确定]
    启动 httpd:                                               [确定]

    9、查看扩展是否已加载

    [root@localhost jianbao]# /usr/local/php/bin/php -m
    [PHP Modules]
    Core
    ctype
    curl
    date
    dom
    ereg
    fileinfo
    filter
    ftp
    gd
    hash
    iconv
    json
    libxml
    mbstring
    mcrypt
    mysql
    openssl
    pcre
    PDO
    pdo_sqlite
    Phar
    posix
    Reflection
    session
    SimpleXML
    soap
    SPL
    SQLite
    sqlite3
    standard
    tokenizer
    xml
    xmlreader
    xmlwriter
    zip
    zlib
    
    [Zend Modules]

    soap 已在里面啦,安装成功!!!

    今后,要安装其他的扩展,同理可得。


    /usr/local/php/bin/phpize

    #安装 soap扩展  configure 命令: 

    ./configure --with-php-config=/usr/local/php/bin/php-config --enable-soap

    #安装 socket扩展 configure 命令: 

    ./configure --with-php-config=/usr/local/php/bin/php-config --enable-sockets

    #安装 pdo_mysql扩展  configure 命令: 

    ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql

    #安装 mysqli扩展  configure 命令: 

    ./configure --with-php-config=/usr/local/php/bin/php-config -with-mysqli=/usr/local/mysql/bin/mysql_config

    #另外,别忘了给 php.ini 添加的相应的扩展配置:

    extension=soap.so
    extension=sockets.so
    extension=pdo_mysql.so
    extension=mysqli.so
    

    Windows服务器下PHP扩展的启用比较简单,官方扩展说明:http://www.php.net/manual/zh/install.windows.extensions.php

    Linux扩展:http://pecl.php.net/package/PDO_MYSQL (pdo_mysql)

    延伸阅读:

    CentOS6.3编译安装LAMP(1):准备工作

    CentOS6.3编译安装LAMP(2):编译安装 Apache2.2.25

    CentOS6.3编译安装LAMP(2):编译安装 Apache2.4.6

    CentOS6.3编译安装LAMP(3):编译安装 MySQL5.5.25

    CentOS6.3编译安装LAMP(4):编译安装 PHP5.2.17

    CentOS6.3编译安装LAMP(4):编译安装 PHP5.3.27

    PHP5不重新编译,如何安装自带的未安装过的扩展,如soap扩展?  

    Linux下,如何给PHP安装pdo_mysql扩展

    CentOS6.x编译安装Memcached的PHP客户端memcache

    CentOS 7.x,不重新编译 PHP,动态安装 imap 扩展

  • 相关阅读:
    今天没有去上班
    [转]分析ASP.NET读取XML文件4种方法
    Div+CSS布局入门教程
    net 怎么调用迅雷
    类图(Class Diagram)
    asp.net删除文件夹后引起Session丢失的解决办法[转]
    对象图(Object Diagram)
    C#使用Strings.StrConv进行简繁体转换
    ASP.NET使用Memcached高缓存实例(入门级)[转]
    类似豆丁网、百度文库的开源文档播放器源码下载[转]
  • 原文地址:https://www.cnblogs.com/52php/p/5666946.html
Copyright © 2011-2022 走看看