Ubuntu VPS setup at digital ocean

This blog is hosted on an Ubuntu 14.04 VPS at digital ocean. This post is mainly a reminder for me of the tutorials I used to set things up, however you might find it a helpful guide as well.

As you might expect, this is the place to start after you’ve created a droplet and received a password from digital ocean.

Next, I setup my ssh key using a unique ssh port (call it XXXX) and a non-default identity file identity.pub. My command to copy my key to the server was then of the form:

$ ssh-copy-id -i ~/.ssh/identity.pub -p XXXX username@xxx.xxx.xxx.xx

Once setup, the ssh command is:

$ ssh -i ~/.ssh/identity.pub -p XXXX username@xxx.xxx.xxx.xx

To save myself from typing this every time, I added this identity to my ~/.ssh/config file with an entry like:

Host           christrelioff.ws
HostName       xxx.xxx.xxx.xx
Port           XXXX
IdentityFile   ~/.ssh/identity
User           username

This allows me to ssh with the simple command (tab auto-complete works too):

$ ssh chrisstrelioff.ws

and the correct port, identity file, etc are used.

$ sudo apt-get install ufw

Once installed, the status can be seen using the command:

$ sudo ufw status

At this point there should be nothing to see– simply a notification that the status is inactive. So, let’s set some default policies:

$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing

This denies everything incoming and allows all outgoing by default. Next, we must allow incoming ssh. By default ssh uses port 22 and the command to allow incoming ssh is

$ sudo ufw allow ssh

However, it you’ve setup ssh on a different port (as I have) – say port XXXX – the command becomes:

$ sudo ufw allow XXXX/tcp

We’ll also allow www traffic:

$ sudo ufw allow www

Finally, to enable (be sure that you’ve setup your ssh access before doing this!):

$ sudow ufw enable

Now trying the $ sudo ufw status command should reflect the ports we allowed above and indicate the firewall is active. Finally, to disable or reset ufw the commands are

$ sudo ufw disable


$ sudo ufw reset

For more information on ufw try: ufw or setup a firewall.

$ sudo apt-get install nginx

nginx is active by default when installed. So, open a browser and go to the IP/url for your VPS to see the default nginx welcome page.

To stop, start or restart nginx try:

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

Finally, for the initial setup, let’s make sure that nginx starts when the server is rebooted:

$ sudo update-rc.d nginx defaults

This command should say that stop/start links for nginx already existed. The next step is set up for the actual content– try how to setup nginx server blocks on ubuntu 14.04.

  • Update the server

    The server will need to updated at times and this has to be done via the terminal. Fortunately updates are pretty simple. For typical (minor) updates of installed software the following will get things done:

$ sudo apt-get update
$ sudo apt-get upgrade

For major updates (like a kernel upgrade) more has to be done:

$ sudo apt-get update
$ sudo apt-get dist-upgrade

Typically this is followed by a reboot of the server:

$ sudo reboot

That’s it for all the basic updating needs.


api [1]   arduino [1]   audio [2]   audio features [1]   babel [1]   Bayesian [7]   Beta [1]   blog setup [1]   bootstrap [1]   bottleneck [1]   c++ [1]   caret [1]   cmpy [1]   conditional probability [6]   coursera [1]   coursera intro to data science [3]   css [1]   cython [1]   d3 [2]   decision trees [2]   diy [1]   dropbox [1]   dsp [1]   e1071 [1]   essentia [1]   garmin [1]   geojson [1]   ggplot2 [1]   gis [2]   git [1]   gnuplot [1]   graphs [1]   html5 [1]   igraph [1]   ipython [1]   javascript [7]   joint probability [6]   json [1]   LaTeX [2]   LDA [1]   Lea [2]   machine learning [3]   marginal probability [6]   matplotlib [1]   meteor [2]   mir [1]   MongoDB [3]   music [2]   my python setup [5]   my ubuntu setup [10]   mysql [3]   networks [1]   networkx [1]   nodejs [5]   npm [3]   numexpr [1]   numpy [1]   octave [1]   Open Oakland [2]   openpyxl [1]   pandas [3]   patsy [1]   pip [2]   pweave [1]   pygraphviz [1]   pymc [1]   PySoundFile [2]   python [15]   Python [1]   python 2.7 [5]   python 3.4 [2]   pyyaml [1]   qgis [1]   R [1]   randomForest [1]   restview [1]   resume [1]   rpart [1]   running [1]   scikit-learn [3]   scipy [1]   screen [1]   server setup [1]   shapefile [1]   social networks [1]   Socrata [1]   sound [2]   sphinx [1]   sql [4]   sqlite3 [1]   ssh [1]   ssh keys [1]   statsmodels [1]   supervised learning [2]   sympy [1]   tableau [1]   tinkerer [2]   topic models [1]   tree [1]   ubuntu 14.04 [13]   Ubuntu 14.04 [3]   ubuntu 16.04 [4]   vim [2]   virtualbox [1]   virtualenv [4]   virtualenvwrapper [3]   VPS [1]   vundle [1]   webpack [1]   yaml [1]