Created
February 27, 2013 15:41
-
-
Save steve-taylor/5048848 to your computer and use it in GitHub Desktop.
Install and configure a Java EE 6 web stack on Centos 6 consisting of OpenJDK 1.7.0, GlassFish 3.1.2.2, Maven 3.0.4, PostgreSQL 9.1 and PostgreSQL JDBC drivers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# PostgreSQL user that owns the schema (i.e. executes the deployment DDL). Change as needed. | |
DBSCHEMA_OWNER='app_owner' | |
DBSCHEMA_OWNER_PW='app_owner' | |
# PostgreSQL user that your web app uses to connect to the database (i.e. executes queries and DML). Change as needed. | |
DBSCHEMA_USER='app_user' | |
DBSCHEMA_USER_PW='app_user' | |
yum -y install java-1.7.0-openjdk-devel | |
wget http://download.java.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2.zip | |
unzip glassfish-3.1.2.2.zip | |
wget http://www.us.apache.org/dist/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz | |
tar zxvf apache-maven-3.0.4-bin.tar.gz | |
# Change GlassFish http/https ports from 8080/8181 to 80/443. (Could use iptables to redirect instead.) | |
sed -i 's/\(.\+\)port=\"8080\"\(.\+\)/\1port=\"80\"\2/g' ~/glassfish3/glassfish/domains/domain1/config/domain.xml | |
sed -i 's/\(.\+\)port=\"8181\"\(.\+\)/\1port=\"443\"\2/g' ~/glassfish3/glassfish/domains/domain1/config/domain.xml | |
# Install PostgreSQL drivers in GlassFish | |
~/apache-maven-3.0.4/bin/mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DgroupId=postgresql -DartifactId=postgresql -Dversion=9.1-901-1.jdbc4 | |
cp ~/.m2/repository/postgresql/postgresql/9.1-901-1.jdbc4/postgresql-9.1-901-1.jdbc4.jar ~/glassfish3/glassfish/domains/domain1/lib/ext/ | |
# Install PostgreSQL | |
# 1. Install RPMforge | |
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm | |
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt | |
rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm | |
# 2. Add PostgreSQL yum repo. | |
wget http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-centos91-9.1-4.noarch.rpm | |
rpm -ivh pgdg-centos91-9.1-4.noarch.rpm | |
# 3. Exclude postgresql* from Centos base and update packages. | |
sed -i '/\[base\]/a exclude=postgresql*' /etc/yum.repos.d/CentOS-Base.repo | |
sed -i '/\[updates\]/a exclude=postgresql*' /etc/yum.repos.d/CentOS-Base.repo | |
# 4. Install and start PostgreSQL 9.1 | |
yum -y install postgresql-server | |
chkconfig postgresql-9.1 on | |
service postgresql-9.1 initdb | |
service postgresql-9.1 start | |
# 5. Create a super user | |
su - postgres -c "echo -e \"admin\nadmin\" | createuser -s root -P" | |
# 6. Enable PostgreSQL password authentication | |
echo -e "\ | |
# TYPE DATABASE USER ADDRESS METHOD\n\ | |
\n\ | |
local all postgres peer\n\ | |
\n\ | |
local all $DBSCHEMA_OWNER md5\n\ | |
host all $DBSCHEMA_OWNER 127.0.0.1/32 md5\n\ | |
host all $DBSCHEMA_OWNER ::1/128 md5\n\ | |
\n\ | |
local all $DBSCHEMA_USER md5\n\ | |
host all $DBSCHEMA_USER 127.0.0.1/32 md5\n\ | |
host all $DBSCHEMA_USER ::1/128 md5\n\ | |
" > /var/lib/pgsql/9.1/data/pg_hba.conf | |
# 7. Setup pgpass file. | |
echo "*:*:*:$DBSCHEMA_OWNER:$DBSCHEMA_OWNER_PW" > ~/.pgpass | |
echo "*:*:*:$DBSCHEMA_USER:$DBSCHEMA_USER_PW" >> ~/.pgpass | |
chmod 0600 ~/.pgpass | |
# 8. Restart database to make all the above settings changes take effect. | |
service postgresql-9.1 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment