Search

Jan 31, 2015

Maven and Java

JAVA
Step by step install JAVA in ubuntu:
http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux

Step 1: Download and extract JDK

Step 2: Create folder /usr/local/java:
sudo mkdir -p /usr/local/java 
+ Copy jdk folder to /usr/local/java:
sudo cp -a /home/huynhsang/Downloads/jdk1.8.0_31/ /usr/local/java/

Step 3: Edit the system PATH file /etc/profile :
sudo gedit /etc/profile 
or
sudo nano /etc/profile

Step 4: edit profile file:
JAVA_HOME=/usr/local/java/jdk1.8.0_31
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

Step 5: Save and Quit.

Step 6:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_31/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_31/bin/javac" 1 
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_31/jre/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_31/bin/javac 
sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_31/bin/javaws

Step 7: Check JDK version
java -version

JAVA
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default

$ java -version

===================================================

MAVEN

Step 1: Download maven http://maven.apache.org/download.cgi
Step 2: Extract to path: /usr/local/apache-maven/apache-maven.3-2-5
+ Create apache-maven:
sudo mkdir /usr/local/apche-maven
+ Copy apache-maven-3.2.5 to /usr/local/apche-maven:
sudo cp -a /home/huynhsang/Downloads/apache-maven-3.2.5 /usr/local/apche-maven/


Step 3: sudo gedit /etc/profile

JAVA_HOME=/usr/local/java/jdk1.8.0_31
JRE_HOME=$JAVA_HOME/jre

M2_HOME=/usr/local/apche-maven/apache-maven-3.2.5/
M2=$M2_HOME/bin
MAVEN_OPTS="-Xms256m -Xmx512m"

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$M2:$M2_HOME
export JAVA_HOME
export JRE_HOME
export M2_HOME
export M2
export PATH

Jan 27, 2015

Create shortcut in Ubuntu

Create file: name.desktop and edit file with gedit
[Desktop Entry]
Version=1.0
Name=GrooveNet (app name)
Comment=Launch GrooveNet
Exec=/Downloads/GrooveNet-master/project/bin/groovenet (file link)
Icon=/path/to/icon.png (icon link)
Terminal=true (or false)
Type=Application
Categories=Utility;Application;
Rename file to *.desktop
Right click -> Properties -> permissions -> Check Allow executing file as program

Jan 9, 2015

Install nodeJS, redis, redis commander, MongoDB, Nginx

nodeJS + NPM install

sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
node -v
npm -v

Or (Recommended):
sudo apt-get install nodejs
sudo apt-get install npm

Check:
node -v
npm -v

If you type "node -v" and receive a message: The program 'node' can be found in the following packages. Step by step:
1. Run: which node
and in my case it displayed /usr/sbin/node.
2. If it says command not found, skip to 3. Remove it by
sudo rm /usr/sbin/node
3. Run: which nodejs
in my case it displayed /usr/bin/nodejs
4. Make a link
sudo ln -s /usr/bin/nodejs /usr/bin/node
OR
sudo ln -s /usr/bin/nodejs /usr/sbin/node
Re-check: node -v


===========================================================
Redis 
Reference: http://blog.chungkol.com/2014/03/nosql-how-to-install-redis-server-from.html 

Step 1. Before you install redis, there are a couple of prerequisites that need to be downloaded to make the installation as easy as possible:
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install tcl8.5

Step 2. Goto redis.io and get stable release version of redis
sudo wget http://download.redis.io/releases/redis-2.8.17.tar.gz
tar -xvf redis-2.8.17.tar.gz
cd redis-2.8.17/src
sudo make install

Step 3. Install redis server by script
cd ../utils
sudo ./install_server.sh
Enter ...

Step 4. Start and stop redis services:
sudo /etc/init.d/redis_6379 start
sudo /etc/init.d/redis_6379 stop

Step 5. Access to redis command line
redis-cli
Notes: if old redis is running, stop it before install.

 redis-server --version

===========================================================

Redis-commander

Step 0: If you dont' have NPM
sudo apt-get install npm

Install:
sudo chown -R $USER /usr/local
sudo npm install -g redis-commander

redis-commander

===========================================================
MongoDB

Install:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

mongod --version

Command
sudo service mongod start
sudo service mongod stop
sudo service mongod restart

Getting Started with MongoDB
http://docs.mongodb.org/manual/tutorial/getting-started/
The MongoDB instance stores its data files in /var/lib/mongodb and its log files in/var/log/mongodb by default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.
If you change the user that runs the MongoDB process, you must modify the access control rights to the/var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.

===========================================================
Forever

sudo npm install forever -g
forever --version

Start server

node /data/HGTV/server.js
forever start -a /data/HGTV/server.js
forever stop -a /data/HGTV/server.js
forever restart -a /data/HGTV/server.js

===========================================================
Maven

sudo apt-get install maven
mvn -v

===========================================================
Nginx

sudo apt-get update
sudo apt-get install nginx
nginx -v

sudo service nginx stop
sudo service nginx start
sudo service nginx restart

We can make sure that our web server will restart automatically when the server is rebooted by typing:
sudo update-rc.d nginx defaults

This should already be enabled by default, so you may see a message like this:
System start/stop links for /etc/init.d/nginx already exist.

===========================================================
PHP

sudo apt-get update
sudo apt-get install php5 php5-mhash php5-mcrypt php5-curl php5-cli php5-gd libcurl3 php5-intl php5-xsl php5-mysql
php -v