前提:
安装gbase8s csdk
https://www.modb.pro/db/1790005561907548160
安装unixODBC
[root@gbase184 ~]# rpm -qa | grep -i unixODBC
unixODBC-2.3.1-11.el7.x86_64
unixODBC-devel-2.3.1-11.el7.x86_64
[root@gbase184 ~]#
配置环境变量
cd /etc/ld.so.conf.d/
vim gbasedbt-x86_64.conf
/opt/GBASE/gbase/lib
/opt/GBASE/gbase/lib/cli
/opt/GBASE/gbase/lib/esql1.编译安装php7.4.33
--依赖安装 yum install -y epel-release yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libpng libpng-devel libjpeg libjpeg-devel freetype-devel sqlite sqlite-devel tar -zxvf php-7.4.33.tar.gz cd php-7.4.33 ./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-mbstring --with-openssl --with-mysqli --with-pdo-mysql --with-curl --with-zlib --enable-zip --enable-soap --enable-pcntl --enable-bcmath --enable-calendar --with-gettext --disable-fileinfo --with-unixODBC --enable-odbc --enable-pdo --with-pdo-odbc--报错处理 checking whether to enable multibyte regex support (requires oniguruma)... yes checking for oniguruma... no configure: error: Package requirements (oniguruma) were not met: No package 'oniguruma' found Consider adjusting the PKG_CONFIG_PATH environment --安装(包上传) https://github.com/kkos/oniguruma--解压编译安装 ./configure --prefix=/usr --libdir=/lib64 make sudo make install 简单说明:需要有“--libdir=/lib64”参数。如果不使用这个参数,编译PHP仍将报错,编辑ldconfig配置无法解决问题。目前还不清楚问题的缘由。 make make install
2.pdo-gbasedbt插件安装
tar -zxvf PDO_GBASEDBT-1.3.6.tgz cd PDO_GBASEDBT-1.3.6 phpize ./configure --with-php-config=/usr/local/php74/bin/php-config --with-pdo-gbasedbt=/opt/GBASE/gbase--pdo_odbc安装编译 ./configure --with-pdo-odbc=shared,unixODBC,/usr/ --enable-odbc=shared,unixODBC,/usr/ --with-unixODBC=shared,/usr/ make make install --添加扩展 cd /usr/local/php74/etc vim php.ini extension=pdo_gbasedbt.so --检查 php -m | grep -i pdo_gbasedbt
3.php-fpm配置
cd /usr/local/php74/etc
cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d
cp www.conf.default www.conf
--修改www.conf
; 修改user和group值为ngingx,因为nginx使用nginx用户及组
user = nginx
group = nginx
; 打开环境变量配置参数
clear_env = no
; 使用PDO_GBASEDBT连接时需要配置以下环境变量
env[GBASEDBTDIR] = /opt/GBASE/gbase
-启动fpm
php-fpm -R4.安装nginx及配置
yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-pcre
--添加系统服务
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=Nginx Web Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl start nginx
systemctl enable nginxnginx配置
cd /usr/local/nginx/conf
vim nginx.conf
--添加
location ~* \.php$ {
# fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
--保存
systemctl reload nginx
--添加测试文件
cd /usr/local/nginx/www
vim pdoodbc.php
";
echo "drop table tabpdogbasedbt
";
$sql="drop table if exists tabpdogbasedbt";
$dbh->exec($sql);
echo "create table tabpdogbasedbt
";
$sql="create table tabpdogbasedbt(col1 int, col2 varchar(255), primary key(col1))";
$dbh->exec($sql);
echo "insert into tabpdogbasedbt
";
$sql="insert into tabpdogbasedbt values(?,?)";
$stmt = $dbh->prepare($sql);
$stmt->execute([1,'南大通用']);
$stmt = $dbh->prepare($sql)->execute([2,'南大通用北京分公司']);
echo "select from tabpdogbasedbt
";
$sql="select * from tabpdogbasedbt";
$stmt = $dbh->query($sql);
$rows = $stmt->fetchAll();
echo "<table><tr>";
echo "<th>col1</th>";
echo "<th>col2</th></tr>";
foreach($rows as $row) {
# 需要使用大写字段名称
echo "<tr><td>$row[0]</td>";
echo "<td>$row[COL2]</td></tr>";
}
echo "</table>";
?>5.网页访问测试
http://192.168.31.155/pdoodbc.php
初始化表 tabpdogbasedbt
drop table tabpdogbasedbt
create table tabpdogbasedbt
insert into tabpdogbasedbt
select from tabpdogbasedbt
col1 col2
1 南大通用
2 南大通用北京分公司
文章参考
https://gbasedbt.com/index.php/archives/591/
更多精彩内容尽在南大通用技术社区https://www.gbase.cn/community,南大通用致力于成为用户最信赖的数据库产品供应商。
最后修改时间:2025-06-16 14:03:52
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




