CentOSのインストール
CentOS6.4だと凄い楽。最初からこのサイト見ておけばよかった・・・。
Windows 8 メモ / CentOS 6.4をHyper-Vにインストールする
続いて、GlassFishを入れるときに参考にしたサイト
Apacheの起動時のエラー対応
Apacheのエラー:Could not reliably determine the server’s fully qualified domain name〜とメッセージが出たときの対応
mod_proxy
Glassfish Apacheとの連携 (mod_proxy_http)
mod_proxyのProxyPassReverseの意味がようやく理解できた
実際に/etc/httpd/conf/httpd.confに追加した設定は以下のとおり。
# # Proxy Server directives. Uncomment the following lines to # enable the proxy server: # <IfModule mod_proxy.c> <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /helloworld/ http://127.0.0.1:8080/helloworld/ ProxyPassReverse /helloworld/ http://127.0.0.1:8080/helloworld/ # # Enable/disable the handling of HTTP/1.1 "Via:" headers. # ("Full" adds the server version; "Block" removes all outgoing Via: headers) # Set to one of: Off | On | Full | Block # #ProxyVia On # # To enable a cache of proxied content, uncomment the following lines. # See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details. # #<IfModule mod_disk_cache.c> # CacheEnable disk / # CacheRoot "/var/cache/mod_proxy" #</IfModule> # </IfModule>
SELinuxで変更した値の永続化
SELinuxが有効になってると、apacheがTCP通信しようとしたときにエラー起きるので許可してやらないといけないとか。
http://morphmorph.com/archives/103
GUIからやると楽ちんなのでお勧め。
PostgreSQL
PostgreSQLのサイトからrpmをダウンロードしてインストールしてDB初期化して起動
sudo rpm -i ダウンロードしたrpmファイル sudo yum -y install postgresql92-server.x86_64 sudo service postgresql-9.2 initdb sudo chkconfig postgresql-9.2 on sudo service postgresql-9.2 start
postgresユーザーのパスワードを変える
sudo passwd postgres
postgresユーザーになって、外部からの接続を受け付けるようにする
cd /var/lib/pgsql/9.2/data vi postgresql.conf # 外部からの接続許可 listen_addresses = '*' vi pg_hba.conf # どこからなんでも来いという感じ(ちゃんと設定しないとね…) host all all all trust
設定が終わったのでサービス再起動
sudo service postgresql-9.2 restart
ファイアーウォールの設定で5432に穴をあける
JavaJava
適当にpostgresqlからデータをとってきて表示するアプリを作ってhelloworld.warという名前に固める。
ユーザーのホームディレクトリにwarとリソースの設定を書いたglassfish-resources.xml(NetBeansで作ると作ってくれてる)とpostgresqlのjdbcドライバを置く。
/usr/glassfish/glassfish3/glassfish/domains/domain1/libにjdbcドライバをコピー
/usr/glassfish/glassfish3/binに移動
リソースの追加とデプロイ
sudo ./asadmin add-resources /home/okazuki/glassfish-resources.xml # 途中で管理コンソールのパスワードとか聞かれるので入れる sudo ./asadmin deploy /home/okazuki/helloworld.war # 途中で管理コンソールのパスワードとか聞かれるので入れる
デプロイが終わるので、apache経由でアクセスできるか確認してみる。