2010年2月9日火曜日

覚書  あぱっちとぽすぐれなど

★Webサーバの構築
centOS5.0にはApache2.2が標準で採用されている

①インストール
yum -y install httpd

②マニュアルもインストール
yum -y install httpd -manual ???? なぜかエラー

※yumをつかってインストールしたときのディレクトリ構成
http://www.atmarkit.co.jp/flinux/rensai/apache2_01/apache01b.html

/etc/httpd/conf/   httpd.confなど設定ファイル
/usr/lib/httpd/build/   拡張モジュール作成時に使用
/usr/lib/httpd/modules/   拡張モジュール
/usr/sbin/   apachectl、httpdなどの実行ファイル
/usr/share/man/   マニュアル(man形式)
/var/log/httpd/   ログファイル
/var/www/    
  ├─ cgi-bin/   CGIスクリプト
  ├─ error/   エラーメッセージファイル
  ├─ html/   Webサイトのドキュメントルート
  ├─ icons/   アイコンファイル
  └─ manual/   マニュアル(HTML形式)

③Apacheの設定
/etc/httpd/conf/httpd.conf
・ServerNameの追加
・AddDefaultCharset UTF-8をコメントアウト

④Apacheの起動と停止
/etc/init.d/http -k start
/etc/init.d/http -k stop

⑤Apacheno自動起動設定
chkconfig httpd on

★postgreSQLのインストール
①インストール
yum install postgresql-server

※インストールの確認
rpm -qa | grep postgres
postgresql-libs-8.1.4-1.1
postgresql-8.1.18-2.el5_4.1
postgresql-server-8.1.18-2.el5_4.1

※ユーザーも作られている
id postgres
uid=26(postgres) gid=26(postgres) 所属グループ=26(postgres)

※パスワードの設定
rootでpasswd postgres

②サービスの登録
chkconfig postgresql on
※確認
chkconfig --list postgresql

④起動
/etc/init.d/postgresql start

⑤psql接続 ・・・以下postgre

※データベースの一覧を表示
psql -l
List of databases
Name | Owner | Encoding
-----------+----------+----------
postgres | postgres | EUC_JP
template0 | postgres | EUC_JP
template1 | postgres | EUC_JP
(3 rows)

※新規ユーザーの作成 --> nitc (デフォルトの設定ではOSユーザーと一致している必要がある?)
createuser nitc
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) y
CREATE ROLE

※2009/02/02・・・CGIから利用するため、OS認証→パスワード認証に変更

※1)設定ファイル変更 /var/lib/pgsql/data/pg_hba.conf もともとはident sameuser
※ local all all password

※2)サービス再起動
※/etc/init.d/postgresql restart
※rootにて

※3)パスワードの設定
※ALTER ROLE nitc with password 'xxx';
※ALTER ROLE postgres with password 'xxx';

⑥データベースの作成
※先ほど作成したデータベースユーザーとLinuxのユーザーは一致している必要がある

su -nitc 
$ createdb hogedb
CREATE DATABASE
$ psql -l
List of databases
Name | Owner | Encoding
-----------+----------+----------
hogedb | nitc | EUC_JP
postgres | postgres | EUC_JP
template0 | postgres | EUC_JP
template1 | postgres | EUC_JP
(4 rows)

★postgresqlのトランザクション管理
・明示的にトランザクションを開始しないと、自動でcommitされる
  BEGIN ENDまたはCOMMIT ROLLBACK

★FTPでASCIIモードで転送しても、改行コードが自動で変更されない
http://www.aconus.com/~oyaji/ftp/vsftpd_rpm.htm
→ linux 側のFTPデーモンの設定が、デフォルトでasciiモード不可になっていたため。
→ /etc/vsftpd/vsftpd.confを編集
ascii_download_enable=YES (デフォルト:NO)
ascii_upload_enable=YES (デフォルト:NO)
    >>ASCⅡモードでのダウンロード・アップロードが何故かデフォルトで不可になっている。 YES にしないと、CGI が動かないという痛い目にあう。
→デーモン再起動
    /sbin/service vsftpd restart

0 件のコメント: