Setting up a dev environment - bahkified/Notes GitHub Wiki

##Minimum Recommended Specs for development VM This development environment runs an instance of Nginx, an instance of Tomcat, and an instance of MongoDB. For this it needs:

  • 20 GB hdd
  • 4 GB RAM
  • CentOS-6.4-x86_64-minimal.iso from \mdfiles\public\SoftwareDevelopment\JavaTeam\downloads

Setup your hosts file

This is done so that you can ssh into your box without getting a "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED" error. This is useful if you've created other boxes that hijax the same ports

vi /etc/hosts
add 'lens' to the end of the 127.0.0.1 line

Forward the virtualized ports

--VBoxManage createvm "LENS" --mount Centos minimal --Host Linux systems can't forward ports lower than 1024 without root privs VBoxManage modifyvm "LENS" --natpf1 "web,,,10080,,80" VBoxManage modifyvm "LENS" --natpf1 "web,,,10443,,443" #remember to specify https VBoxManage modifyvm "LENS" --natpf1 "web,,,18081,,8081" VBoxManage modifyvm "LENS" --natpf1 "web,,,10022,,22"

http://www.linux-mag.com/id/7673/ http://wiki.centos.org/HowTos/Virtualization/VirtualBox

##Setup llp user

useradd llp
passwd llp
usermod -a -G wheel llp

##Enable networking

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /root/ifcfg-eth0.bak
vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
/etc/init.d/network restart

http://www.cyberciti.biz/faq/setting-up-a-linux-for-dhcp/

##Setup autosigin in from the llp-build user

ssh-keygen 
ssh-copy-id -i .ssh/id_rsa.pub llp@localhost

##Add llp to the bottom of sudoers

visudo 
comment out `Defaults    requiretty`
add `llp ALL=(ALL) NOPASSWD: ALL` 

##Install all of the deps All of the following must be run as root

yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install -y java-1.7.0-openjdk.x86_64
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel pcre-devel
yum install -y puppet 
yum install -y wget unzip zip

curl -L get.rvm.io | bash -s stable
rvm install 2.0
rvm pkg install openssl
gem install rake

##Download & Extract Tomcat, Mongo & Nginx

mkdir -p /data1/llp/
chown llp. -R data1
cd /data1/llp/

wget http://mirror.metrocast.net/apache/tomcat/tomcat-7/v7.0.50/bin/apache-tomcat-7.0.50.tar.gz
wget http://www.mongodb.org/dr/fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz/download
wget http://nginx.org/download/nginx-1.5.9.tar.gz

tar xf apache-tomcat-7.0.50.tar.gz
ln -s apache-tomcat-7.0.50 tomcat

tar xf mongodb-linux-x86_64-2.4.9.tgz
ln -s mongodb-linux-x86_64-2.4.9 mongodb

tar xf nginx-1.5.9.tar.gz

#Compile & Install nginx

mv nginx-1.5.9 nginx-1.5.9-src
cd nginx-1.5.9-src
./configure --prefix=/data1/llp/nginx --with-http_ssl_module --with-pcre-jit
make 
make install 

##Start Mongo (This has to be done every restart atm)

mkdir -p /data1/llp/mongodb/db/
/data1/llp/mongodb/bin/mongod --dbpath=/data1/llp/mongodb/db/ --fork --logpath /var/log/mongodb.log

##add firewall rules for the server

#delete rule: 		iptables -D INPUT 5
#verify: 			netstat -tulpn 
#list rules: 		iptables --line -vnL
#log all traffic:	iptables -I INPUT 5 -j LOG --log-level 4
#iptables by default logs to /var/log/messages

iptables -I INPUT 5 -p tcp --dport 80 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 443 -j ACCEPT
iptables -I INPUT 5 -p tcp --dport 8081 -j ACCEPT 
service iptables save

Sources http://www.cyberciti.biz/faq/rhel-fedorta-linux-iptables-firewall-configuration-tutorial/

##Clone and deploy app

yum install git vim
git clone <url>
cd llp-master/llp-server/build/
rake release --
rake deploy_with_automation_jar ENV=local VERSION=1.3.0

#Setup shared folders between host and guest VM

yum update
reboot
mount -t vboxsf [-o OPTIONS] vmshare ~/

Example:

sudo mount -t vboxsf -o uid=501,gid=502 llp llp

Sources:Install VBox Guest Additions, https://www.virtualbox.org/manual/ch04.html#sharedfolders

#Java compiler The regular OpenJDK is not an actual JDK, instead it only has a JRE (no compiler). If you need the compiler, for example, to execute Gradle, you must install openjdk devel.

yum -y install java-1.7.0-openjdk-devel.x86_64
⚠️ **GitHub.com Fallback** ⚠️