1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php环境informix 在Nginx + php-fpm(fastcgi)环境下配置informix的连接

php环境informix 在Nginx + php-fpm(fastcgi)环境下配置informix的连接

时间:2022-07-26 02:01:56

相关推荐

php环境informix 在Nginx + php-fpm(fastcgi)环境下配置informix的连接

buildconf: checking installation...

buildconf: autoconf version 2.59 (ok)

buildconf: Your version of autoconf likely contains buggy cache code.

Running cvsclean for you.

To avoid this, install autoconf-2.13.

rebuilding configure

这时,需要编译autoconf-2.13来避免此问题,编译autoconf-2.13的方法如下:

解压缩autoconf-2.13.tar.gz包,然后编译即可,而不需要覆盖现在的autoconf

nginx% gunzip autoconf-2.13.tar.gz | tar xvf -

在autoconf-2.13目录下

nginx% ./configure --prefix=/home/nginx/autoconfig213

完成后

nginx% make && make install

此时,autoconf编译完成,在环境变量中增加PHP_AUTOCONF和PHP_AUTOHEADER

nginx% export PHP_AUTOCONF=/home/nginx/autoconf213/bin/autoconf

nginx% export PHP_AUTOHEADER=/home/nginx/autoconf213/bin/autoheader

再次在php-5.2.8下执行重建configure,确认configure文件重写生成。

nginx% ./buildconf --force

然后可以通过./configure --help 来检查应该含有--with-informix[=DIR] 这样的选项了。

在编译php-fpm前,在环境中指定INFORMIXDIR(必须,若未配置必须要--with-informix中指定目录)和INFORMIXSERVER

nginx% export INFORMIXDIR=/opt/informix

nginx% export INFORMIXSERVER=ids_online_net

注:以下编译选项还包含了mysql的连接,若不需要可以不选。

nginx% ./configure \

--prefix=/home/nginx/php \

--enable-fastcgi \

--enable-fpm \

--with-mysql \

--with-informix \

--with-zlib \

--with-curl \

--with-freetype-dir \

--enable-ftp \

--enable-zip

nginx% make all (编译所有)

nginx% make install (编译安装,完成安装)

检查安装

nginx% cd /home/nginx/php/bin

nginx% ./php -v(显示如下内容,表示安装正常)

PHP 5.2.8 (cli) (built: Aug 11 22:53:04)

Copyright (c) 1997- The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998- Zend Technologies

将php-5.2.8目录下的php.ini-dist 复制到/home/nginx/php/lib/php.ini

修改配置文件/home/nginx/php/etc/php-fpm.conf,找到部分(该部分的内容是指定php的环境变量)

增加以下两项。(示例中使用用户环境变量,即上面指定的两个环境变量)

$INFORMIXDIR

$INFORMIXSERVER

修改PATH,使用$PATH替换掉默认变量

$PATH

完成以上后,启动php-fpm

nginx% /home/nginx/php/sbin/php-fpm start

3.nginx的安装

nginx% tar -xzvf nginx-0.8.54.tar.gz(解压缩包nginx-0.8.54,生成目录nginx-0.8.54)

nginx% cd nginx-0.8.54

nginx% ./configure \

--prefix=/home/nginx (指定--prefixm,配置前,应先安装好pcre-devel)

nginx% make (编译)

nginx% make install (编译安装)

配置nginx

修改/home/nginx/conf/nginx.conf 配置文件,需做如下修改

server {

listen 8080; (修改所使用的端口)

server_name localhost; (修改所使用的服务器名,可以使用IP地址)

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

roothtml;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,$fastcgi_script_name 应改为$document_root$fastcgi_script_name,或者使用绝对路径

完成配置后启动

nginx% /home/nginx/sbin/nginx

编写个phpinfo.php文件保存在/home/nginx/html/目录下,文件内容如下:

然后在浏览器中打开,输出应当有informix的项目,并且需要注意php的变量中存在INFORMIXDIR和INFORMIXSERVER,如图所示:

编写个连接至informix数据库的php文件testifx.php,ifx_connect的参数含义是(dbname@INFORMIXSERVER, user, password)

$conn_id = ifx_connect ("sysmaster@ids_online_net", "informix", "informix");

if ($conn_id){

echo "connect success!";

} else {

echo "connect failed!";

}

?>

若是指定的数据库正常运行的话,应该能得到输出 connect success!

结束语:弄这个弄了好几天,到今天01:30(.02.02,春节咯!^_^)总算是搞定了,中间因为php的环境问题做了好几次(使用php -e testifx.php一直都正常,在浏览器中输出错误),偶然看到php-fpm的进程中含有配置文件名,这才找到关键所在,加上环境就一切都好了!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。