使用 apt-get install 安装了 nginx, php5 和 postgresql
但是 php 无法连接 postgresql, 出现如下错误.
Fatal error: Call to undefined function pg_connect()
网上搜索了,说检查 php.ini 中是否将 pgsql.so 加载了.
使用 php -i | grep pgsql 能看到已经加载了 pgsql.so, 但是web server上当 php 启动时, 却没有加载 pgsql
下面网站上也讨论了这个问题
Re: [Ubuntu 12.04] Postgresql + PHP + Apache, pg_conect() undefined
Thanks SeijiSensei for writing anything and generally thank you everyone for no help at all. I got used to it on this forum.
For the record, I have not resolved this particular issue. There is one
thing however - pgsql is not included when php is ran by webserver. If I
run it from CLI and check php -i.... the php_pdo_pgsql and php_pgsql
are both loaded!
If you happen to know how to make it work, please, be so kind and reply. Any kind of input is priceless.
用命令 apt-get install phppgadmin 安装 phppgadmin
将 /usr/share/phppgadmin 整个目录拷贝到 /mnt/www/ 下, 在浏览器中打开
提示: 您的 PHP 中没有完整的数据库支持。
看来只能重新编译 PHP 了.
首先卸载 PHP
service nginx stop
apt-get remove nginx
apt-get remove php5*
下载 Nginx 1.6.2 , pcre-8.20, zlib-1.2.8
和 php5.6.6
tar -xzvf pcre-8.20
tar -xzvf zlib-1.2.8
tar -xzvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.20 --with-zlib=../zlib-1.2.8
make
make install
然后可以运行 nginx 了
cd /usr/local/nginx
./nginx
当然也可以修改一下配置文件. (在 PHP安装好后仍然需要进一步配置) 关于 PHP设置部分如下
location ~* \.php$ {
fastcgi_index index.php;
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;
}
PHP 的安装稍微复杂一些, 具体可以参考
http://devincharge.com/compiling-php-5-4-ubuntu-12-04/
make
make test
make install
配置详见
其中有一些内容需要修改的.
启动 php
/usr/local/php/sbin/php-fpm
最后重启 nginx
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx
阅读(2069) | 评论(0) | 转发(0) |