Linux commands handy for web application deployments.

Do you need to be a Linux expert do deploy your application in the cloud? Short answer is - No.

I have been playing a lot with public cloud platforms recently while looking for a perfect production environment for Bushido, and I must admit that Linux is the most popular OS for the cloud. Pretty much every cloud provider supports Linux images - and it makes sense to use this OS due to its undisputed advantages like stability, performance, security and the most important to me - its open source policy. Bushido beta was first running on Google Cloud, but I have decided to move it to Digital Ocean.

It was a great experience to configure Google Cloud Platform for Bushido, and see it running on the same infrastructure as Google's products, but I finally came to a conclusion that I need something cheaper to run the beta on. Digital Ocean was first mentioned to me by Denis Sheremetov (cheers!), and it indeed saves money - operational cost dropped by 77%. It also gave me the opportunity to play with a fresh Linux installation called a cloud "Droplet", learn a bit about the OS, its basic apps and commands.

My application runs on Ubuntu 14.04, so the cheat sheet below applies to this specific Linux distribution. A few commands and apps handy for a typical web application deployments on Linux are:

Use shell to connect to Mongo:
mongo --host mysite.com --port 27017 -u username -p password --authenticationDatabase mysite

Use shell to connect to Mongo:
mongo --host mysite.com --port 27017 -u username -p password --authenticationDatabase mysite

Remove all files from a folder:
sudo rm -r /opt/tomcat/logs/*.*

Create a directory:
sudo mkdir -p /var/www/mysite

Remove all files from a folder:
sudo rm -r /opt/tomcat/logs/*.*

Create a directory:
sudo mkdir -p /var/www/mysite

Transfer directory ownership to current user:
sudo chown -R $USER:$USER /var/www/mysite

Set write permissions for owner:
sudo chmod -R 755 /var/www

Copy file:
cp /var/www/mysite/html/index.html /var/www/myothersite/html/

Create a symbolic link:
sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/

Remove a file or symbolic link:
sudo rm /etc/nginx/sites-enabled/default

Add a new user:
adduser johndoe

Add a user to sudo group:
gpasswd -a johndoe sudo

Update package index:
sudo apt-get update

Install an application:
sudo apt-get install tomcat

Set system variable:
sudo nano ~./bash_profile and add line export LOGS_HOME=/opt/tomcat/logs

Restart a service:
sudo service nginx restart

With this basic command set, I was able to configure Ubuntu Linux OS on Digital Ocean to host bushidowallet.com. Conclusions are, Linux is easy to use, predictable and user friendly. Highly recommended both Linux and Digital Ocean.

Sign up to Digital Ocean

Comments

comments powered by Disqus