Note: This article isn’t about comparing Amazon EC2 and DigitalOcean Droplet. It’s just why I decided to shift and how easy it was. Hey, guys! I daydream myself as a Software Engineer, who loves software designing and development to build something useful for humans. Developing a software not only involves programming but also to deploy it(assuming it to be a in this article) to be easily accessible anytime anywhere over the internet. This deployment stuff obviously requires a server to host the site and in order to serve the user-made calls. Behind the human-computer interaction, there’s a lot of fuzz going on the servers. Static sites, which are simply built for the purpose of displaying information like portfolio sites, are easy to host and generally don’t require a server. There are lots of good options out there in the market like Github’s free hosting which is handy to operate and very popular these days.The server is essential when there’s a need to process user input, persist data and retrieve it from a database, or do some computational work. Following is the minimalistic software lifecycle chart. web-app configuring it properly dedicated This post happens to be a lengthy one as it actually explains a step-by-step procedure to shift from one server to another. Why don’t you grab up a cup of coffee to enjoy the show? Sometime back in time, I developed two web-apps back to back, officially named as and . [ ] Json2Html Translatr Click names to view live demo helps in converting JSON structure into a well defined tabular structure whereas tries to help the (multilingual) audience to translate a text or a paragraph into more than one language at once. Please give both the apps a shot and provide some feedback. Thank You! 🙏 Json2Html Translatr I choose Python as the programming language for both the apps just because I prefer it’s ease of use. Once the apps were programmed and ready for the general availability, came the time to deploy them. As it was my first time deploying some real stuff, I chose which provides a rich ecosystem of pre-integrated extensions and services to deploy great apps at scale with little configuration. But I wasn’t happy at all. I observed to be slow plus I always like things to be managed my own way. Moreover, I consider over getting things done with ready-made solutions to be a great self-learning experience in any field. I usually learn technologies by actually building stuff myself. Hands-on experience is the power bank of knowledge.Soon after some time, I went with Amazon Ec2 for it’s most obvious reasons. H eroku Heroukuapp trying things Elastic Compute Cloud ( ) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. Amazon Amazon EC2 Amazon It’s a very popular cloud hosting provider in the market, a reliable, secure, completely controlled, and easy to start with provider. Moreover, it offers one year long free-tier plan for the beginners to get hands-on experience with AWS Cloud Services. Who wouldn’t like to play with such liberty? 😎 So, I went through the relevant and must admit that the quality of docs is very very impressive. They are written in a well-organized manner, covering exactly what the user actually wants. I think Amazon has used Machine Learning here too. 😜 AWS Amazon Docs Online My EC2 t2.micro instance was ready to rule after managing a lot of struggle configuring it like a new born baby. The server was quite a noob and obeyed my commands well and was up to serve the audience. It was a moment of gratification. Ah! The time hits the door exactly after a year and reminded me of the free tier plan’s expiry. I started getting emails to pay off the bill for the extra graceful month. The cost, as it reads, was something around $22/month. I couldn’t believe that my personal portfolio cum blogging site, running just two more python apps could generate such a handsome amount of money. I was totally confused but as soon as the next email arrived in my inbox clearly indicating me to pay the another next month bill which was projected to be somewhat around $25 otherwise the instance would forcefully be shut down; I decided to look out for other options. For a moment, I couldn’t understand the dilemma I was in; Whether I should start making the real value from the organic traffic which could save me a couple of dollars from my pants or I should first prepare myself to switch to some lower-range option available and then think of monetization. This hit me hard to think wisely. Finally, after researching and discussing stuff with my colleagues, I considered DigitalOcean to be best suitable for my overall personal requirements. DigitalOcean Setup DigitalOcean is a simple cloud hosting provider built for developers. Every droplet which spins up is a new VPS for our personal use. It’s very easy to deploy a blazing fast SSD cloud server in just 55 seconds within an easy-to-use control panel. Plans start at $5 per month and include 512MB RAM, 20GB SSD Disk, and 1TB Transfer. A damn good deal, indeed. I signed up instantly with a new account. Check out these before entering billing info to get some . Get flat $10 discount using . Once the account was created, verified and billing info was provided, I proceeded to create a new droplet. promo codes good discount this link STEP 1: Choose an image I considered as I’m much more familiar with this OS. Also, most of the DigitalOcean blogs are written considering this OS only. Ubuntu 14.04 STEP 2: Choose the droplet size I went with for its obvious benefits in lesser cost. $5 plan STEP 3: Choose a datacenter I choose based on my website traffic history. I went through my Google Analytics account associated with my website and realized most of the visitors are coming from the US. So, it’s better to choose the datacenter located nearest to the majority of visitors’ geographical location to enjoy the benefits of reduced latency. New York 3 STEP 4: Other Information I created a new ssh key for the droplet. cd ~/.sshssh-keygen -t rsa -f ubuntu_512mb_nyc3_01 -C “ ”ssh-add ~/.ssh/ubuntu_512mb_nyc3_01cat ubuntu_512mb_nyc3_01.pub myemail@gmail.com I Copied and pasted the content in the box shown below. The SSH key is very private, so please don’t share it or post it publicly. STEP 5: And it’s done! I hit the button and Voila! I have my own server up and running with my preferred choice of OS installed in it. Create Add a domain Now, point server’s IP to the domain name. I entered my personal website URL to start managing my DNS within my newly created DigitalOcean account. To make a new hostname, I only need to fill in the A record. If you are using an IPv6 address, you should enter it into the AAAA record. : I entered in my server’s IP address and the hostname itself. The hostname will be prepended to the domain name. My screen looked like this: A Records Read more on in detail. the DigitalOcean blog Point to DigitalOcean nameservers from common domain registrars I use Namecheap as my default registrar. It’ simply awesome. I bound my domain name to one of the droplets by changing the domain name servers with the domain’s registrar.Read more on in detail. the DigitalOcean blog Install apache and get the static site up and running I usually prefer Apache over Nginx as I have been using it for long and I’m less accustomed to Nginx. Apache is a free open source software which runs over 50% of the world’s web servers. The Apache web server is the most popular way of serving web content on the internet. To install apache, I ssh to my server. ssh root@12.34.56.789 And installed apache via the following commands. sudo apt-get updatesudo apt-get install apache2 That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. The page should display the words “It works!” like . http://12.34.56.789). this How to Find your Server’s IP address The following command helps revealing server’s IP address. ifconfig eth0 | grep inet | awk '{ print $2 }' Securely transfer files from server to remote and vice-versa I used sftp for transferring files between a remote server and a local server. SFTP, which stands for SSH File Transfer Protocol, or Secure File Transfer Protocol, is a separate protocol packaged with SSH that works in a similar way over a secure connection. The advantage is the ability to leverage a secure connection to transfer files and traverse the filesystem on both the local and remote system. Read more on in detail which is an ultimate guide on how to transfer files from one server(eg: A_mazon EC2_) to local server(eg: ) and then to the another server(eg: ). the DigitalOcean blog personal system DO droplet This way of transferring is obviously very verbose in nature. One can opt for easy to use interface like thatof . I have used it and is quite useful sometimes. Cyberduck Deploying Python Applications My two web apps: and , which I mentioned earlier, both uses , a micro-framework for based on . Json2Html Translatr Flask Python Werkzeug My next step was to deploy them successfully on the server to be accessible over the internet to the audience. : Install mod_wsgi STEP 1 sudo apt-get install libapache2-mod-wsgi python-dev Enable mod_wsgi STEP 2: sudo a2enmod wsgi : Creating app STEP 3 Flask Check out the following apps with their source code to build up a basic Flask app.1. — 2. — Json2Html View Source Code Translatr View Source Code Always have all your requirements in a file. Let’s name it: Its content can be manually written or run which will list down all the installed modules so far in the virtual environment. Eg: requirements.txt. pip freeze Flask==0.10.1requests : Setting up Python environment using STEP 4 virtualenv Using pip to install virtualenv and Flask. Installed pip through apt-get. sudo apt-get install python-pip Use pip to install using the following command: virtualenv sudo pip install virtualenv I created a virtual Python environment( is the name I gave to my temporary environment). VENV sudo virtualenv VENV Now, I installed Flask in that environment by activating the virtual environment with the following command: source /bin/activate VENV Now, I installed all the dependencies of my app as listed in above. requirements.txt pip install -r requirements.txt I verified if everything’s working fine by running: python __init__.py I got a message that my server is running on It guaranteed that everything was working fine. 127.0.0.1:5000 . I created Virtual Hosts for different apps with different domains to point at. Creating Virtual Hosts has been covered up in next section. Read more on in detail. the DigitalOcean blog Set Up Apache Virtual Hosts Virtual Host is the basic unit which allows the administrator to use one server to host multiple domains or sites off of a single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than one site off of a single VPS. Change directory as follows: STEP 1: cd /etc/apache2/sites-enabled Sample Virtual Host file, let’s call it STEP 2: example.conf vim example.conf # Content of example.conf <VirtualHost *:80>ServerAdmin admin@example.comServerName example.comServerAlias DocumentRoot /var/www/example.com/public_htmlErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost> www.example.com Enable the Virtual Host STEP 3: sudo a2ensite example.conf STEP 4: Restart the apache server sudo service apache2 restart Read more on in detail. the DigitalOcean blog Hope you might have learned something new in this post.For any queries, drop me words at .Please recommend, tweet and share to boost my confidence for more write-ups. Thanks a lot! varun2902@gmail.com I’m a social person. Would love to be connected on the following: | | | | Website Github Twitter LinkedIn StackOverflow