Linux Centos 7
Membangun Web Server

Web Server : Apache Tomcat
Language : JSP (Java Server Pages)
Database : PostgreSQL

Tools : PuTTY & WinSCP.


Uninstall Apache



# sudo yum erase httpd-tools apr apr-util
	

Install JDK



# yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
	
Melihat versi java

# java -version
	
Konfigurasi Java Home Environment

# sudo update-alternatives --config java
# vim /etc/environment
	

JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64"

Simpan dengan

:wq
	
Edit bash profile

# vim ~/.bash_profile
	

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64
export PATH=$JAVA_HOME/bin:$PATH

Save & reload bash profile

# source ~/.bash_profile
	
Cek JAVA_HOME

# echo $JAVA_HOME
	

Install Apache Tomcat



# groupadd tomcat
# useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
# cd /opt
# wget http://mirror.wanxp.id/apache/tomcat/tomcat-8/v8.0.43/bin/apache-tomcat-8.0.43.tar.gz
# tar -xzvf apache-tomcat-8.0.43.tar.gz
# chown -hR tomcat:tomcat tomcat
	
Test Tomcat

# /opt/tomcat/bin/startup.sh
	
View Process

# ps aux
	

# yum provides */netstat
# yum install net-tools
# netstat -plntu
	
Firewall

# iptables -L
# iptables -F
# iptables -L
# service iptables save
	
Restart Tomcat

# /opt/tomcat/bin/shutdown.sh
# /opt/tomcat/bin/startup.sh
	

Install PostgreSQL


SET TIMEZONE

# ln -s /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
	
Install

# chmod +x postgresql-9.3.17-1-linux-x64.run
# ./postgresql-9.3.17-1-linux-x64.run
# systemctl start postgresql-9.3
# su - postgres
	

Copy JDBC file


Restore Database

# /opt/PostgreSQL/9.3/bin/pg_restore -i -h localhost -p 5432 -U postgres -d xsatriya -v "/opt/xsatriya.backup"
	
Backup Database

# /opt/PostgreSQL/9.3/bin/pg_dump -i -h localhost -p 5432 -U postgres -F c -b -v -f "/opt/backupdb/xsatriya.backup" xsatriya
	

Create .pgpass in /root/.pgpass for automatic password

Set permission .pgpass

# chmod 600 /root/.pgpass
	

CRONJOB



# sudo yum update
# sudo rpm -q cronie
# sudo yum install cronie
	
Create Command

# sudo crontab -e
	

https://www.howtoforge.com/tutorial/how-to-install-tomcat-on-centos/
http://jurnalinux.blogspot.co.id/2016/04/install-database-postgresql-95-di.html
https://www.linode.com/docs/databases/postgresql/securely-manage-remote-postgresql-servers-with-pgadmin-on-windows
https://linuxandryan.wordpress.com/2013/03/07/creating-and-using-a-pgpass-file/
https://serverfault.com/questions/579233/permission-denied-on-owned-file
https://www.rosehosting.com/blog/automate-system-tasks-using-cron-on-centos-7/
http://www.pixelstech.net/article/1339424625-Create-cron-job-on-CentOS