Entries
2012.05/17 [Thu]
2012.05/11 [Fri]
2012.04/14 [Sat]
2012.04/04 [Wed]
2012.03/22 [Thu]
2012.03/20 [Tue]
2012.03/20 [Tue]
PostgresとPerlの連携
【メモ】
http://www.atmarkit.co.jp/flinux/rensai/postgres03/postgres03.html
「2.PerlによるPostgreSQLの操作」をやってみました。
[root]#rpm -qa |grep postgresql
postgresql-server-8.4.4-2.el6.x86_64
postgresql-odbc-08.04.0200-1.el6.x86_64
postgresql-docs-8.4.4-2.el6.x86_64
postgresql-libs-8.4.4-2.el6.x86_64
postgresql-8.4.4-2.el6.x86_64
[root]#./test1.pl
Can't locate Pg.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5
/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
/usr/lib64/perl5 /usr/share/perl5 .) at ./test1.pl line 2.
BEGIN failed--compilation aborted at ./test1.pl line 2.
[root]#cat test1.pl
#!/usr/bin/perl
use Pg;
<略>
※Pgが必要らしい
※「Can't locate Pg.pm in @INC」で検索してみるとCPANを実行しないといけないらしい
プロキシサーバを利用しているので設定
[root]#export ftp_proxy=http://ftp_proxy:8000/
[root]#export http_proxy=http://http_proxy:8000/
※CPAN実行途中でプロキシのIDとパスワードを聞かれる
[root]#perl -MCPAN -e shell
※選択肢は[ENTER]でOK
cpan> m Pg
Module id = Pg
DESCRIPTION PostgreSQL SQL database interface
CPAN_USERID MERGL (Edmund Mergl)
CPAN_VERSION 1.009000
CPAN_FILE M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz
DSLIP_STATUS Rdcf? (released,developer,C,functions,)
INST_FILE (not installed)
cpan> install Pg
<前略>
"http://www.perl.org/CPAN/authors/id/M/ME/MERGL/CHECKSUMS"
Checksum for /root/.cpan/sources/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz ok
pgsql_perl5-1.9.0/
pgsql_perl5-1.9.0/eg/
pgsql_perl5-1.9.0/eg/ApachePg.pl
pgsql_perl5-1.9.0/eg/example.pl
pgsql_perl5-1.9.0/eg/lo_demo.pl
pgsql_perl5-1.9.0/Changes
pgsql_perl5-1.9.0/MANIFEST
pgsql_perl5-1.9.0/Makefile.PL
pgsql_perl5-1.9.0/Pg.pm
pgsql_perl5-1.9.0/Pg.xs
pgsql_perl5-1.9.0/README
pgsql_perl5-1.9.0/test.pl
pgsql_perl5-1.9.0/typemap
<後略>
※findでMakefileの場所を探す。
[root]# cd /root/.cpan/build/pgsql_perl5-1.9.0-IIPFPZ/
[root]# perl Makefile.PL
Configuring Pg
Remember to actually read the README file !
please set environment variables POSTGRES_INCLUDE and POSTGRES_LIB !
※READMEを見ていなかった…。
※READMEから抜粋
The Makefile checks the environment variables POSTGRES_INCLUDE and
POSTGRES_LIB, to find the library libpq.so and the include file
libpq-fe.h.
※findでlibpq.soの場所を探す
[root]# export POSTGRES_LIB=/usr/lib64/
[root]# export POSTGRES_INCLUDE=/usr/lib64/
[root]# perl Makefile.PL
Configuring Pg
Remember to actually read the README file !
OS: linux
Checking if your kit is complete...
Looks good
Writing Makefile for Pg
[root]# make
Pg.xs:16:22: error: libpq-fe.h: そのようなファイルやディレクトリはありません
[root]# rpm -ivh postgresql-devel-8.4.4-2.el6.x86_64.rpm
警告: postgresql-devel-8.4.4-2.el6.x86_64.rpm: ヘッダ V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
準備中... ########################################### [100%]
1:postgresql-devel ########################################### [100%]
[root]# updatedb
[root]# locate libpq-fe.h
/usr/include/libpq-fe.h
[root]# make
※いくつか警告が出るが無視
[root]# make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/Pg/Pg.bs
Installing /usr/local/lib64/perl5/auto/Pg/Pg.so
Installing /usr/local/lib64/perl5/Pg.pm
Installing /usr/local/lib64/perl5/auto/Pg/autosplit.ix
Installing /usr/local/share/man/man3/Pg.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
[root]# cd /var/www/html/
[root]# ./test1.pl
name telno email
--------------------------------------
[root]#vi test1.pl
$dbuser = "user1";
$conn = Pg::connectdb("dbname=$dbname user=$dbuser");
[root]# ./test1.pl
name telno email
--------------------------------------
R.Munechika 070-1234-5678 munetika@hogehoge.com
H.Nishida 070-2345-6789 nishida@hogehoge.com
T.Miyahara 070-3456-7890 miyahara@hogehoge.com
※表示できた
[root]# ./test2.pl
OK
[root]# ./test1.pl
name telno email
--------------------------------------
R.Munechika 070-1234-5678 munetika@hogehoge.com
H.Nishida 070-2345-6789 nishida@hogehoge.com
T.Miyahara 070-3456-7890 miyahara@hogehoge.com
K,Hamano 070-8888-8888 hamano@email.net
※追加できた
http://www.atmarkit.co.jp/flinux/rensai/postgres03/postgres03.html
「2.PerlによるPostgreSQLの操作」をやってみました。
[root]#rpm -qa |grep postgresql
postgresql-server-8.4.4-2.el6.x86_64
postgresql-odbc-08.04.0200-1.el6.x86_64
postgresql-docs-8.4.4-2.el6.x86_64
postgresql-libs-8.4.4-2.el6.x86_64
postgresql-8.4.4-2.el6.x86_64
[root]#./test1.pl
Can't locate Pg.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5
/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
/usr/lib64/perl5 /usr/share/perl5 .) at ./test1.pl line 2.
BEGIN failed--compilation aborted at ./test1.pl line 2.
[root]#cat test1.pl
#!/usr/bin/perl
use Pg;
<略>
※Pgが必要らしい
※「Can't locate Pg.pm in @INC」で検索してみるとCPANを実行しないといけないらしい
プロキシサーバを利用しているので設定
[root]#export ftp_proxy=http://ftp_proxy:8000/
[root]#export http_proxy=http://http_proxy:8000/
※CPAN実行途中でプロキシのIDとパスワードを聞かれる
[root]#perl -MCPAN -e shell
※選択肢は[ENTER]でOK
cpan> m Pg
Module id = Pg
DESCRIPTION PostgreSQL SQL database interface
CPAN_USERID MERGL (Edmund Mergl
CPAN_VERSION 1.009000
CPAN_FILE M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz
DSLIP_STATUS Rdcf? (released,developer,C,functions,)
INST_FILE (not installed)
cpan> install Pg
<前略>
"http://www.perl.org/CPAN/authors/id/M/ME/MERGL/CHECKSUMS"
Checksum for /root/.cpan/sources/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz ok
pgsql_perl5-1.9.0/
pgsql_perl5-1.9.0/eg/
pgsql_perl5-1.9.0/eg/ApachePg.pl
pgsql_perl5-1.9.0/eg/example.pl
pgsql_perl5-1.9.0/eg/lo_demo.pl
pgsql_perl5-1.9.0/Changes
pgsql_perl5-1.9.0/MANIFEST
pgsql_perl5-1.9.0/Makefile.PL
pgsql_perl5-1.9.0/Pg.pm
pgsql_perl5-1.9.0/Pg.xs
pgsql_perl5-1.9.0/README
pgsql_perl5-1.9.0/test.pl
pgsql_perl5-1.9.0/typemap
<後略>
※findでMakefileの場所を探す。
[root]# cd /root/.cpan/build/pgsql_perl5-1.9.0-IIPFPZ/
[root]# perl Makefile.PL
Configuring Pg
Remember to actually read the README file !
please set environment variables POSTGRES_INCLUDE and POSTGRES_LIB !
※READMEを見ていなかった…。
※READMEから抜粋
The Makefile checks the environment variables POSTGRES_INCLUDE and
POSTGRES_LIB, to find the library libpq.so and the include file
libpq-fe.h.
※findでlibpq.soの場所を探す
[root]# export POSTGRES_LIB=/usr/lib64/
[root]# export POSTGRES_INCLUDE=/usr/lib64/
[root]# perl Makefile.PL
Configuring Pg
Remember to actually read the README file !
OS: linux
Checking if your kit is complete...
Looks good
Writing Makefile for Pg
[root]# make
Pg.xs:16:22: error: libpq-fe.h: そのようなファイルやディレクトリはありません
[root]# rpm -ivh postgresql-devel-8.4.4-2.el6.x86_64.rpm
警告: postgresql-devel-8.4.4-2.el6.x86_64.rpm: ヘッダ V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
準備中... ########################################### [100%]
1:postgresql-devel ########################################### [100%]
[root]# updatedb
[root]# locate libpq-fe.h
/usr/include/libpq-fe.h
[root]# make
※いくつか警告が出るが無視
[root]# make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/lib64/perl5/auto/Pg/Pg.bs
Installing /usr/local/lib64/perl5/auto/Pg/Pg.so
Installing /usr/local/lib64/perl5/Pg.pm
Installing /usr/local/lib64/perl5/auto/Pg/autosplit.ix
Installing /usr/local/share/man/man3/Pg.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
[root]# cd /var/www/html/
[root]# ./test1.pl
name telno email
--------------------------------------
[root]#vi test1.pl
$dbuser = "user1";
$conn = Pg::connectdb("dbname=$dbname user=$dbuser");
[root]# ./test1.pl
name telno email
--------------------------------------
R.Munechika 070-1234-5678 munetika@hogehoge.com
H.Nishida 070-2345-6789 nishida@hogehoge.com
T.Miyahara 070-3456-7890 miyahara@hogehoge.com
※表示できた
[root]# ./test2.pl
OK
[root]# ./test1.pl
name telno email
--------------------------------------
R.Munechika 070-1234-5678 munetika@hogehoge.com
H.Nishida 070-2345-6789 nishida@hogehoge.com
T.Miyahara 070-3456-7890 miyahara@hogehoge.com
K,Hamano 070-8888-8888 hamano@email.net
※追加できた
2011.12/17 [Sat]
Apache-Tomcatの連携
【環境】
OS:WindowsServer2008R2
Web:Apache2.2.x
AP:Tomcat6.0.x
[Apache]=Apacheインストールディレクトリ
[Tomcat]=Tomcatインストールディレクトリ
【メモ】
TomcatのWebポート(8080)の無効
[Tomcat]\conf\server.xml
mod_proxy_ajpモジュールの有効(#を外す)
[Apache]\conf\httpd.conf
コンテキストパスで設定した値に設定
[Tomcat]\conf\Catalina\localhost\hoge.xml
[Tomcat]\conf\Catalina\localhost\manager.xml
http-proxy.confを読み込み
[Apache]\conf\httpd.conf
Apache、Tomcatの再起動
http://localhost/hoge/
http://localhost/manager/html
に接続できればOK
OS:WindowsServer2008R2
Web:Apache2.2.x
AP:Tomcat6.0.x
[Apache]=Apacheインストールディレクトリ
[Tomcat]=Tomcatインストールディレクトリ
【メモ】
TomcatのWebポート(8080)の無効
[Tomcat]\conf\server.xml
<!--
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
mod_proxy_ajpモジュールの有効(#を外す)
[Apache]\conf\httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
コンテキストパスで設定した値に設定
[Tomcat]\conf\Catalina\localhost\hoge.xml
[Tomcat]\conf\Catalina\localhost\manager.xml
[Apache]\conf\extra\httpd-proxy.conf
<Location /hoge/>
ProxyPass ajp://localhost:8009/hoge/
</Location>
<Location /manager/>
ProxyPass ajp://localhost:8009/manager/
</Location>
http-proxy.confを読み込み
[Apache]\conf\httpd.conf
Include conf/extra/httpd-proxy.conf
Apache、Tomcatの再起動
http://localhost/hoge/
http://localhost/manager/html
に接続できればOK
2011.11/15 [Tue]
2011.11/14 [Mon]








皆さん元気デースカー☆
寂しいおめーらに、2012娘さまがお小遣いを届けに行ってやるぜ~☆
感謝しな☆
http://13H155Vh.bb.z2bmk.net/13H155Vh/