ここでは、「CentOS 5 Sixwish 標準インストールマニュアル、標準最小構成化マニュアル」並びに「Xen Domain-U関連」の最小構成構築の手順に従って構築された環境であることを前提としています。
そのため、異なる方法でインストールした場合は、状況が少し異なるので読替えるなどしてください。
なお、ここでの表記は「Xen Domain-U関連」に記載されている「CentOS 5 on Xen(CnetOS5) Domain-U用最小化手順仕上げ」まで完了した状態から始めている例です。
また、Apacheと連携させる事とPostgreSQLと連携させる事を前提とするため、そちらのインストールも済ませて置いてください。
なお、これに関連してApacheやPostgreSQLの設定ファイルも書き換える事になります。
yumを使ってインストールします。
rpmからインストールする時に厄介なのは、モジュールは別のrpmとして配布されているところです。
また、使用したいモジュールが配布されていない事もあるので、新しい事をやる時には不便さを感じるかも。
但し、PHPアプリは大抵の場合RHELで配布されているバージョンに合わせているのでこれで十分かと。
今回は、PHP本体、CLI、PEARをインストール。
モジュールは、PDO、PostgreSQL、XML、XML-RPC、SOAP、GD、mbstringを入れています。
[root@sixwish ~]# yum -y install php php-common php-cli php-pear \ php-pdo php-pgsql php-xml php-xmlrpc php-soap php-gd php-mbstring Loading "installonlyn" plugin Setting up Install Process Setting up repositories Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for php-gd to pack into transaction set. php-gd-5.1.6-12.el5.i386. 100% |=========================| 16 kB 00:01 ---> Package php-gd.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-pdo to pack into transaction set. php-pdo-5.1.6-12.el5.i386 100% |=========================| 17 kB 00:01 ---> Package php-pdo.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-common to pack into transaction set. php-common-5.1.6-12.el5.i 100% |=========================| 19 kB 00:04 ---> Package php-common.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-pgsql to pack into transaction set. php-pgsql-5.1.6-12.el5.i3 100% |=========================| 17 kB 00:01 ---> Package php-pgsql.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-pear to pack into transaction set. php-pear-1.4.9-4.noarch.r 100% |=========================| 20 kB 00:00 ---> Package php-pear.noarch 1:1.4.9-4 set to be updated ---> Downloading header for php-mbstring to pack into transaction set. php-mbstring-5.1.6-12.el5 100% |=========================| 16 kB 00:02 ---> Package php-mbstring.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-xml to pack into transaction set. php-xml-5.1.6-12.el5.i386 100% |=========================| 17 kB 00:03 ---> Package php-xml.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-soap to pack into transaction set. php-soap-5.1.6-12.el5.i38 100% |=========================| 16 kB 00:01 ---> Package php-soap.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-xmlrpc to pack into transaction set. php-xmlrpc-5.1.6-12.el5.i 100% |=========================| 16 kB 00:05 ---> Package php-xmlrpc.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php to pack into transaction set. php-5.1.6-12.el5.i386.rpm 100% |=========================| 18 kB 00:02 ---> Package php.i386 0:5.1.6-12.el5 set to be updated ---> Downloading header for php-cli to pack into transaction set. php-cli-5.1.6-12.el5.i386 100% |=========================| 17 kB 00:01 ---> Package php-cli.i386 0:5.1.6-12.el5 set to be updated --> Running transaction check --> Processing Dependency: libgmp.so.3 for package: php --> Processing Dependency: libexslt.so.0 for package: php-xml --> Processing Dependency: libgmp.so.3 for package: php-cli --> Processing Dependency: libxslt.so.1 for package: php-xml --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for libxslt to pack into transaction set. libxslt-1.1.17-2.i386.rpm 100% |=========================| 16 kB 00:00 ---> Package libxslt.i386 0:1.1.17-2 set to be updated ---> Downloading header for gmp to pack into transaction set. gmp-4.1.4-10.el5.i386.rpm 100% |=========================| 10 kB 00:00 ---> Package gmp.i386 0:4.1.4-10.el5 set to be updated --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: php i386 5.1.6-12.el5 updates 1.2 M php-cli i386 5.1.6-12.el5 updates 2.2 M php-common i386 5.1.6-12.el5 updates 139 k php-gd i386 5.1.6-12.el5 updates 112 k php-mbstring i386 5.1.6-12.el5 updates 967 k php-pdo i386 5.1.6-12.el5 updates 61 k php-pear noarch 1:1.4.9-4 base 355 k php-pgsql i386 5.1.6-12.el5 updates 65 k php-soap i386 5.1.6-12.el5 updates 135 k php-xml i386 5.1.6-12.el5 updates 93 k php-xmlrpc i386 5.1.6-12.el5 updates 54 k Installing for dependencies: gmp i386 4.1.4-10.el5 base 664 k libxslt i386 1.1.17-2 base 483 k Transaction Summary ============================================================================= Install 13 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 6.5 M Downloading Packages: (1/13): php-gd-5.1.6-12.e 100% |=========================| 112 kB 00:35 (2/13): php-pdo-5.1.6-12. 100% |=========================| 61 kB 00:19 (3/13): php-common-5.1.6- 100% |=========================| 139 kB 00:30 (4/13): libxslt-1.1.17-2. 100% |=========================| 483 kB 00:11 (5/13): php-pgsql-5.1.6-1 100% |=========================| 65 kB 00:15 (6/13): php-pear-1.4.9-4. 100% |=========================| 355 kB 00:07 (7/13): gmp-4.1.4-10.el5. 100% |=========================| 664 kB 00:16 (8/13): php-mbstring-5.1. 100% |=========================| 967 kB 03:55 (9/13): php-xml-5.1.6-12. 100% |=========================| 93 kB 00:21 (10/13): php-soap-5.1.6-1 100% |=========================| 135 kB 00:29 (11/13): php-xmlrpc-5.1.6 100% |=========================| 54 kB 00:10 (12/13): php-5.1.6-12.el5 100% |=========================| 1.2 MB 06:01 (13/13): php-cli-5.1.6-12 100% |=========================| 2.2 MB 09:25 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: php-common ####################### [ 1/13] Installing: gmp ####################### [ 2/13] Installing: php-cli ####################### [ 3/13] Installing: php ####################### [ 4/13] Installing: php-pdo ####################### [ 5/13] Installing: libxslt ####################### [ 6/13] Installing: php-gd ####################### [ 7/13] Installing: php-pgsql ####################### [ 8/13] Installing: php-pear ####################### [ 9/13] Installing: php-mbstring ####################### [10/13] Installing: php-xml ####################### [11/13] Installing: php-soap ####################### [12/13] Installing: php-xmlrpc ####################### [13/13] Installed: php.i386 0:5.1.6-12.el5 php-cli.i386 0:5.1.6-12.el5 php-common.i386 0:5.1.6-12.el5 php-gd.i386 0:5.1.6-12.el5 php-mbstring.i386 0:5.1.6-12.el5 php-pdo.i386 0:5.1.6-12.el5 php-pear.noarch 1:1.4.9-4 php-pgsql.i386 0:5.1.6-12.el5 php-soap.i386 0:5.1.6-12.el5 php-xml.i386 0:5.1.6-12.el5 php-xmlrpc.i386 0:5.1.6-12.el5 Dependency Installed: gmp.i386 0:4.1.4-10.el5 libxslt.i386 0:1.1.17-2 Complete! [root@sixwish ~]#
これでインストール完了です。
バージョンによっては、表示されているパッケージと異なる事もありますが、基本的には大丈夫だと思います。
開発として使うのを前提とした設定を施します。
実際にサービスとして使う場合は少し異なるかも。
[root@sixwish ~]# cp /etc/php.ini /etc/php.ini.`date -I` [root@sixwish ~]# vi /etc/php.ini
*** /etc/php.ini.YYYY-mm-dd YYYY-mm-dd --:--:--.000000000 +0900 --- /etc/php.ini YYYY-mm-dd --:--:--.000000000 +0900 *************** *** 138,144 **** ; servers which are not under your control, because short tags may not ; be supported on the target server. For portable, redistributable code, ; be sure not to use short tags. ! short_open_tag = On ; Allow ASP-style <% %> tags. asp_tags = Off --- 138,144 ---- ; servers which are not under your control, because short tags may not ; be supported on the target server. For portable, redistributable code, ; be sure not to use short tags. ! short_open_tag = Off ; Allow ASP-style <% %> tags. asp_tags = Off *************** *** 259,265 **** ; and below. This directive makes most sense if used in a per-directory ; or per-virtualhost web server configuration file. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. ! ;open_basedir = ; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names. This directive is --- 259,265 ---- ; and below. This directive makes most sense if used in a per-directory ; or per-virtualhost web server configuration file. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. ! open_basedir = /var/www ; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names. This directive is *************** *** 302,308 **** ; (e.g. by adding its signature to the Web server header). It is no security ; threat in any way, but it makes it possible to determine whether you use PHP ; on your server or not. ! expose_php = On ;;;;;;;;;;;;;;;;;;; --- 302,308 ---- ; (e.g. by adding its signature to the Web server header). It is no security ; threat in any way, but it makes it possible to determine whether you use PHP ; on your server or not. ! expose_php = Off ;;;;;;;;;;;;;;;;;;; *************** *** 364,370 **** ; instead (see below). Keeping display_errors enabled on a production web site ; may reveal security information to end users, such as file paths on your Web ; server, your database schema or other information. ! display_errors = Off ; Even when display_errors is on, errors that occur during PHP's startup ; sequence are not displayed. It's strongly recommended to keep --- 364,370 ---- ; instead (see below). Keeping display_errors enabled on a production web site ; may reveal security information to end users, such as file paths on your Web ; server, your database schema or other information. ! display_errors = On ; Even when display_errors is on, errors that occur during PHP's startup ; sequence are not displayed. It's strongly recommended to keep *************** *** 374,380 **** ; Log errors into a log file (server-specific log, stderr, or error_log (below)) ; As stated above, you're strongly advised to use error logging in place of ; error displaying on production web sites. ! log_errors = On ; Set maximum length of log_errors. In error_log information about the source is ; added. The default is 1024 and 0 allows to not apply any maximum length at all. --- 374,380 ---- ; Log errors into a log file (server-specific log, stderr, or error_log (below)) ; As stated above, you're strongly advised to use error logging in place of ; error displaying on production web sites. ! log_errors = Off ; Set maximum length of log_errors. In error_log information about the source is ; added. The default is 1024 and 0 allows to not apply any maximum length at all. *************** *** 572,578 **** ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. ! file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). --- 572,578 ---- ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. ! file_uploads = Off ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). *************** *** 914,920 **** ; This option enables administrators to make their users invulnerable to ; attacks which involve passing session ids in URLs; defaults to 0. ! ; session.use_only_cookies = 1 ; Name of the session (used as cookie name). session.name = PHPSESSID --- 914,920 ---- ; This option enables administrators to make their users invulnerable to ; attacks which involve passing session ids in URLs; defaults to 0. ! session.use_only_cookies = 1 ; Name of the session (used as cookie name). session.name = PHPSESSID *************** *** 973,983 **** session.entropy_length = 0 ; Specified here to create the session id. ! session.entropy_file = ! ;session.entropy_length = 16 ! ;session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. --- 973,983 ---- session.entropy_length = 0 ; Specified here to create the session id. ! ;session.entropy_file = ! session.entropy_length = 32 ! session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. *************** *** 1000,1006 **** ; Select a hash function ; 0: MD5 (128 bits) ; 1: SHA-1 (160 bits) ! session.hash_function = 0 ; Define how many bits are stored in each character when converting ; the binary hash data to something readable. --- 1000,1006 ---- ; Select a hash function ; 0: MD5 (128 bits) ; 1: SHA-1 (160 bits) ! session.hash_function = 1 ; Define how many bits are stored in each character when converting ; the binary hash data to something readable. *************** *** 1008,1014 **** ; 4 bits: 0-9, a-f ; 5 bits: 0-9, a-v ; 6 bits: 0-9, a-z, A-Z, "-", "," ! session.hash_bits_per_character = 5 ; The URL rewriter will look for URLs in a defined set of HTML tags. ; form/fieldset are special; if you include them here, the rewriter will --- 1008,1014 ---- ; 4 bits: 0-9, a-f ; 5 bits: 0-9, a-v ; 6 bits: 0-9, a-z, A-Z, "-", "," ! session.hash_bits_per_character = 6 ; The URL rewriter will look for URLs in a defined set of HTML tags. ; form/fieldset are special; if you include them here, the rewriter will *************** *** 1122,1155 **** [mbstring] ; language for internal character representation. ! ;mbstring.language = Japanese ; internal/script encoding. ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) ! ;mbstring.internal_encoding = EUC-JP ; http input encoding. ! ;mbstring.http_input = auto ; http output encoding. mb_output_handler must be ; registered as output buffer to function ! ;mbstring.http_output = SJIS ; enable automatic encoding translation according to ; mbstring.internal_encoding setting. Input chars are ; converted to internal encoding by setting this to On. ; Note: Do _not_ use automatic encoding translation for ; portable libs/applications. ! ;mbstring.encoding_translation = Off ; automatic encoding detection order. ; auto means ! ;mbstring.detect_order = auto ; substitute_character used when character cannot be converted ; one from another ! ;mbstring.substitute_character = none; ; overload(replace) single byte functions by mbstring functions. ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), --- 1122,1155 ---- [mbstring] ; language for internal character representation. ! mbstring.language = Japanese ; internal/script encoding. ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) ! mbstring.internal_encoding = utf-8 ; http input encoding. ! mbstring.http_input = utf-8 ; http output encoding. mb_output_handler must be ; registered as output buffer to function ! mbstring.http_output = utf-8 ; enable automatic encoding translation according to ; mbstring.internal_encoding setting. Input chars are ; converted to internal encoding by setting this to On. ; Note: Do _not_ use automatic encoding translation for ; portable libs/applications. ! mbstring.encoding_translation = Off ; automatic encoding detection order. ; auto means ! mbstring.detect_order = utf-8 ; substitute_character used when character cannot be converted ; one from another ! mbstring.substitute_character = none; ; overload(replace) single byte functions by mbstring functions. ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), *************** *** 1159,1168 **** ; 1: Overload mail() function ; 2: Overload str*() functions ; 4: Overload ereg*() functions ! ;mbstring.func_overload = 0 ; enable strict encoding detection. ! ;mbstring.strict_encoding = Off [FrontBase] ;fbsql.allow_persistent = On --- 1159,1168 ---- ; 1: Overload mail() function ; 2: Overload str*() functions ; 4: Overload ereg*() functions ! mbstring.func_overload = 0 ; enable strict encoding detection. ! mbstring.strict_encoding = Off [FrontBase] ;fbsql.allow_persistent = On
[root@sixwish ~]#
これで編集完了と。
今回の設定については、PHP/tips/推奨php.ini設定(yohgaki's blogの中の人のWiki)を参照しています。
参照先と異なる場所についてはあくまでも開発用の環境であるためです。
それでは設定が反映されているかを、phpinfoで確認します。
とりあえず、index.phpを作成して、httpdをリスタートします。
[root@sixwish ~]# echo "<?php phpinfo() ?>" > /var/www/html/index.php [root@sixwish ~]# service httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ] [root@sixwish ~]#
この時、設定が誤っているとhttpdが起動しません。その場合は、設定ファイルの修正個所をもう一度見直してください。
正常に起動したら、ブラウザで確認してください。
このままの場合、「http://ホスト名/」でアクセスした場合に、index.htmlのファイルしか応答しない状態です。
そこで、httpd.confを修正して、index.phpもindexとしてみてくれるように変更します。
confファイルをコピーする時に、日付を自動で埋めています。
同じ日に何度も編集する場合は少し変えるなどしてください。
[root@sixwish ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.`date -I`.1 [root@sixwish ~]# vi /etc/httpd/conf/httpd.conf
*** /etc/httpd/conf/httpd.conf.YYYY-mm-dd.1 YYYY-mm-dd --:--:--.000000000 +0900 --- /etc/httpd/conf/httpd.conf YYYY-mm-dd --:--:--.000000000 +0900 *************** *** 387,393 **** # negotiated documents. The MultiViews Option can be used for the # same purpose, but it is much slower. # ! DirectoryIndex index.html index.html.var # # AccessFileName: The name of the file to look for in each directory --- 387,393 ---- # negotiated documents. The MultiViews Option can be used for the # same purpose, but it is much slower. # ! DirectoryIndex index.php index.html index.html.var # # AccessFileName: The name of the file to look for in each directory
[root@sixwish ~]# service httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ] [root@sixwish ~]#
編集が終わったら、サービスを再起動して、ブラウザでindex.phpを外した状態でアクセスしてください。
phpinfoのページが表示されれば完了です。
SELinuxが有効な状態であると、PHPからDBへのアクセスが出来ない状態になります。
そこで、設定を変更して接続を許可するようにします。
まずは本当に接続できないかを確認してみます。
何かと面倒なので、いろいろ手抜きでユーザ、DBを作成して、手抜きコードで接続を試みます。
なお、ここで作成したユーザなどは削除するので安心して進めてください。
[root@sixwish ~]# service postgresql start postgresql サービスを開始中: [ OK ] [root@sixwish ~]# su - postgres -bash-3.1$ createuser -S -D -R apache CREATE ROLE -bash-3.1$ createdb -O apache -E utf-8 apache CREATE DATABASE -bash-3.1$ logout [root@sixwish ~]#
とりあえず、止まっていたPostgreSQLを動かします。
それから、postgresユーザになって、DBユーザ(正しくはロール)を作成、DBを作成します。
これでデータベースが作成できたので、次にPHPのコードをでっち上げます。
コード自体は、PHPのマニュアルにあるサンプルコードを少し変えたものを使用します。
[root@sixwish ~]# rm /var/www/html/index.php rm: remove 通常ファイル `/var/www/html/index.php'? y [root@sixwish ~]# vi /var/www/html/index.php
<?php try { $dbh = new PDO('pgsql:host=localhost;dbname=apache', 'apache', 'apache'); $dbh = null; echo 'OK'; } catch (PDOException $e) { print $e->getMessage(); die(); } ?>
[root@sixwish ~]#
これで準備完了。
ブラウザからアクセスしてみてください。恐らく下記のようなメッセージが表示されると思います。
SQLSTATE[08006] [7] could not connect to server: Permission denied Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?
さて、どうしてこうなるかを順を追って確認してみます。
まず疑わしいところは、PostgreSQLの設定。
postgresql.conf内に、ネットワークからの接続に関する項目があります。ここが拒否設定になっているかも?
という事で、設定ファイルを確認しつつ編集します。
[root@sixwish ~]# cp /var/lib/pgsql/data/postgresql.conf /var/lib/pgsql/data/postgresql.conf.`date -I` [root@sixwish ~]# vi /var/lib/pgsql/data/postgresql.conf
*** /var/lib/pgsql/data/postgresql.conf YYYY-mm-dd --:--:--.000000000 +0900 --- /var/lib/pgsql/data/postgresql.conf.YYYY-mm-dd YYYY-mm-dd --:--:--.000000000 +0900 *************** *** 46,55 **** # - Connection Settings - ! listen_addresses = '*' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost', '*' = all ! port = 5432 max_connections = 100 # note: increasing max_connections costs ~400 bytes of shared memory per # connection slot, plus lock space (see max_locks_per_transaction). You --- 46,55 ---- # - Connection Settings - ! #listen_addresses = 'localhost' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost', '*' = all ! #port = 5432 max_connections = 100 # note: increasing max_connections costs ~400 bytes of shared memory per # connection slot, plus lock space (see max_locks_per_transaction). You
[root@sixwish ~]# service postgresql restart postgresql サービスを停止中: [ OK ] postgresql サービスを開始中: [ OK ] [root@sixwish ~]#
これで再度アクセスしてみてください。
相変わらず同じメッセージが表示されると思います。
こうなるとSELinuxの制約である可能性が高いので、ログを確認してみます。
SELinuxでの不正アクセスなどのログは、/var/log/audit/audit.logに記録されているので、そこをチェックします。
[root@sixwish ~]# grep "avc: denied" /var/log/audit/audit.log type=AVC msg=audit(1188465020.529:262): avc: denied { name_connect } for pid=7077 comm="httpd" dest=5432 scontext=user_u:system_r:httpd_t:s0 tcontext=system_u:object_r:postgresql_port_t:s0 tclass=tcp_socket
上記のログを確認すると、scontext=user_u:system_r:httpd_tが、tcontext=system_u:object_r:postgresql_port_tへアクセスしようとして、deniedされているということです。
これは、httpdが、postgresqlが使用してるポート5432に対してアクセスしようとしているという意味。
ところが、権限上はPostgreSQLしか使用できないように制限がかかっているわけです。
なのでこれを許可するようにすればOKと。
とりあえず、簡単に設定できる項目を確認します。
getseboolコマンドで変更できる項目を確認します。
[root@sixwish ~]# getsebool -a | grep httpd allow_httpd_anon_write --> off allow_httpd_mod_auth_pam --> off allow_httpd_sys_script_anon_write --> off httpd_builtin_scripting --> on httpd_can_network_connect --> off httpd_can_network_connect_db --> off httpd_can_network_relay --> off httpd_disable_trans --> off httpd_enable_cgi --> on httpd_enable_ftp_server --> off httpd_enable_homedirs --> on httpd_rotatelogs_disable_trans --> off httpd_ssi_exec --> off httpd_suexec_disable_trans --> off httpd_tty_comm --> off httpd_unified --> on [root@labsixwish ~]# getsebool -a | grep postgresql postgresql_disable_trans --> off [root@sixwish ~]#
この中から関係のありそうな項目を探すと、httpd_can_network_connect_dbというのが値がoffになっているので、接続NGになっている可能性がありそうです。
というわけで、この項目を on に変更します。
[root@sixwish ~]# setsebool -P httpd_can_network_connect_db 1 [root@sixwish ~]#
これでブラウザからアクセスすると、今度はSQLSTATE[08006] [7] FATAL: Ident authentication failed for user "apache"
と出てくるでしょう。
このメッセージは、pg_hba.confで許可を与えていない事が原因なので、それを許可すればOKです。
流石に直す項目が多いのでそこまでやりませんが……
あとは掃除して終わりにしましょう。
[root@sixwish ~]# su -postgres -bash-3.1$ dropdb apache DROP DATABASE -bash-3.1$ dropuser apache DROP ROLE -bash-3.1$ logout [root@sixwish ~]#
とりあえずここまで