│ │192.168.1.1 ┏┷┓ ┃ ┃ ┃ ┃WEB example1 ┃ ┃ ┗┯┛ │192.168.2.1 │ │192.168.2.2 ┏┷┓ ┃ ┃ ┃ ┃DB example2 ┃ ┃ ┗┯┛ │
[postgres@example2 postgres]$ createdb -E UTF-8 userdic CREATE DATABASE [postgres@example2 postgres]$ psql userdic Welcome to psql 8.0.3, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit userdic=# create table user_dic ( userdic=# id integer, userdic=# midasi text, userdic=# hatuon text, userdic=# yaku text, userdic=# yorei text, userdic=# useragent text, userdic=# reg_date timestamp userdic=# ); userdic=# REVOKE ALL ON TABLE user_dic FROM PUBLIC; userdic=# ALTER TABLE ONLY user_dic ADD CONSTRAINT user_dic_pkey PRIMARY KEY (id); userdic=# ALTER TABLE ONLY user_dic ADD CONSTRAINT user_dic_midasi_key UNIQUE (midasi); userdic=# GRANT SELECT, INSERT, DELETE, UPDATE ON user_dic TO nobody; CREATE TABLE REVOKE NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "user_dic_pkey" for table "user_dic" NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "user_dic_midasi_key" for table "user_dic" GRANT userdic=# \q テーブルの中身。 create table user_dic ( id integer, midasi text, hatuon text, yaku text, yorei text, useragent text, reg_date timestamp ); REVOKE ALL ON TABLE user_dic FROM PUBLIC; ALTER TABLE ONLY user_dic ADD CONSTRAINT user_dic_pkey PRIMARY KEY (id); ALTER TABLE ONLY user_dic ADD CONSTRAINT user_dic_midasi_key UNIQUE (midasi); GRANT SELECT, INSERT, DELETE, UPDATE ON user_dic TO nobody;
スクリプトは、 /home/example1/public_htmlに設置。 ./public_html │ ├─/inc │ ├─global.inc │ └─header.inc ├─index.php ├─editor.php ├─ajax.php ├─userdic.css └─userdic.js global.incの中身。データベースに接続。 <?php $DBconnect = pg_connect('host=192.168.2.2 dbname=userdic port=5432 user=nobody'); ?> ※ DBサーバーの環境に合わせて変更。 userdic.jsの中身。 /*========================================================= グローバル変数の設定 =========================================================*/ var m_strRootUrl = "http://192.168.1.1/~example1/"; ※ Webサーバーの環境に合わせて変更。