inux下编译增加pdo_odbc模块

分类: 服务器 > Linux

1、让用户选择php版本,然后选择要安装的模块。

2、如果没有gcc先安装gcc,然后查询当前目录下的lanmp/php选择版本/etc下是否有选择的模块,如果没有则在/tmp目录下下载http://dl.wdlinux.cn:5180/soft/php-选择版本.tar.gz,然后解压后从中取扩展的模块(可在浏览器中打开看看能否下载下来,解压看看相关目录是否存在你要安装的模块,如果没有那就要另想办法了)。

3、config,make,make install,然后修改php.ini文件中的配置,最后重启服务器。

而对于当前需求来说,不适用的地方有如下:

    1、如果要按装pdo_odbc,需要首先安装unixODBC,config时也要加入此参数。否则安装时会出现如下错误:

checking for selected PDO ODBC flavour... configure: error: Unknown ODBC flavour /usr/local/unixODBC
                            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 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 build as shared the extension filename is always pdo_odbc.so

    上方的错误信息也给出解决方法了,目前看资料选择的是用unxiODBC(其余的未测试)。unxiODBC安装方法如下,参考资料(资料中路径对于我们的需求来说适合):

        1、官网下载最新版本(没有找到npm,所以直接编译安装,也曾尝试过yum安装,虽然能安装成功,但由于路径不对,还是导致pdo_odbc无法安装成功):

wget http://www.unixodbc.org/unixODBC-2.3.4.tar.gz

        2、然后解压:

tar zxvf unixODBC-2.3.4.tar.gz

        3、cd到解压目录,然后config,注意与参考资料中的区别,include、lib等路径必须是在/usr/local下才可以,否则在安装pdo_odbc时会出现错误

./configure --prefix=/usr/local/unixODBC --includedir=/usr/local/include --libdir=/usr/local/lib -bindir=/usr/local/bin --sysconfdir=/usr/local/etc

        如果unixODBC的路径不正确,在安装pdo_odbc时会出现类似错误:

configure: error: Cannot find header file(s) for pdo_odbc

        4、make编译安装

make && make install

4. 切换目录进入php扩展包目录,执行一下命令:

cd php-*/ext/pdo_odbc/
./configure --with-pdo-odbc=unixODBC
make && make install



来源:原创 发布时间:2023-04-10 16:00:22