PHP 中未加载 pgsql.so
我的任务是创建一个访问现有 PostgreSQL 数据库的 PHP 应用程序。这是我第一次使用 Postgre,更不用说 PHP 已经安装在运行该应用程序的 Linux 机器中了。我没有设置这些东西的经验,我只是编码。
我的问题是我似乎无法让 Postgre 扩展在 PHP 中工作。我检查了 php.ini 文件,没有“extension=...”行。所以我添加了“extension=pgsql.so”。然后我检查了“extension_dir”,发现里面只有 2 个文件(ldap.so、phpcups.so),我添加了一个从另一个 Linux 机器上获取的 pgsql.so 文件。我重新启动了httpd。但它不起作用。我在 phpinfo() 中找不到任何“pgsql”或“postgre”。
原谅我的菜鸟。我对Linux了解太少了。如果您能为我指明正确的方向,我将不胜感激。
我使用了 number5 给出的建议:
老兄,我在 RedHat 上。我使用了你给出的命令的“yum”版本,我得到了这个:
[root@perseus ~]# yum install php-pgsql 加载“installonlyn”插件 设置安装过程 设置存储库 无法检索镜像列表 http://mirrorlist.centos.org/?release =5&arch=x86_64&repo=extras 错误是 [错误号 4] IO 错误: 错误:无法找到存储库的有效基本 URL:额外内容
不幸的是,我使用的 Linux 服务器未连接到互联网。还有其他方式安装吗?
I've been tasked to create a PHP app which accesses an existing PostgreSQL database. This is my first time working with Postgre, not to mention the PHP has already been installed in the Linux box on which the app is supposed to run. I have no experience setting up this stuff, I just code.
My question is that I can't seem to get the Postgre extension working in PHP. I checked the php.ini file, there were no "extension=..." lines. So I added "extension=pgsql.so". I then checked the "extension_dir" and found that there were only 2 files in there (ldap.so, phpcups.so), I added a pgsql.so file taken from another Linux box. I restarted httpd. And it does not work. I couldn't find any "pgsql" or "postgre" in phpinfo().
Forgive my noobness. I know too little Linux. I would really appreciate it if you can point me to the right direction.
I used the suggestion given by number5:
Dude, I'm on RedHat. I used the "yum" version of the command you gave, and I got this:
[root@perseus ~]# yum install php-pgsql
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=extras error was
[Errno 4] IOError:
Error: Cannot find a valid baseurl for repo: extras
UNFORTUNATELY, the Linux server I'm using is NOT connected to the Internet. Any other way to install?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这取决于您使用的 Linux 发行版。
如果您使用 Ubuntu/Debian,您需要:
Fedora/CentOS
通常您可以通过以下方式找到您使用的发行版:
It depends on which Linux distro you are using.
If you are using Ubuntu/Debian, you need to:
Fedora/CentOS
usually you can find out which distro you are on by:
在 CentOS 扩展上,在 /etc/php.d 中为每个 php 扩展创建单独的 *.ini 文件,
因此,不要更改主 *.ini 文件,而是创建 /etc/php.d/pgsql.ini 并在其中添加一行
然后,您需要使用以下命令重新启动 Apache
但最好的自动化方法是仅键入
在您的情况下,由于 yum 配置中的一些问题,该方法不起作用。转到/etc/yum-repos.d
类型
向下滚动到 [extras] 部分并确保其如下所示:
如果需要,请更正它,保存文件 (Ctrl-X) 并执行以下操作:
然后尝试重复
On CentOS extensions create separate *.ini file one per each php extension in /etc/php.d
So, don't alter main *.ini file, but create /etc/php.d/pgsql.ini and add there a line
Then you will need to restart Apache using
But the best automated way is to just type
In your case that didn't work because of some problems in yum configuration. Go to /etc/yum-repos.d
Type
Scroll down to [extras] section and ensure it is like this:
Correct it if needed, save file (Ctrl-X) and do the following:
Afterwards try to repeat
来查看您必须编辑哪个 php.ini
<?php echo 'ini: ', get_cfg_var('cfg_file_path');
to see which php.ini you have to edit我的操作系统 Linux mint kde 也有同样的问题
如果您使用php5.6,则必须安装。
之后您必须在“php.ini”文件中更改扩展名称。
'dll' 到 'so'
例如,
My operation system Linux mint kde and there was same issue
You must install if you are use php5.6
After you must change extention name in "php.ini" file.
'dll' to 'so'
For example