Installing nodejs, nginx, and ghost on Digital Ocean Droplet Week of November 10, 2013 - networksolutions.com -- buy a domain name. - digitalocean.com -- create an account -- purchase the $5 per month Droplet. --- I used Ubuntu Linux. -- Digital Ocean will e-mail the username and password for the Linux server. This info is used to log into the server with SSH. -- while logged into the Digital Ocean dashboard: --- click DNS and add the domain name purchased above. the domain name will be associated with the droplet created, but also need to add the domain name to the DNS setting. --- add the Digital Ocean name servers to the Network Solutions account for the domain name. - log into the Digital Ocean server and change the password. - have root access to the server. - it's clean, simple, bare-bones Linux install. - need to install gcc. - need to install unzip. - need to isntall curl. h2. Installing Node.js https://www.digitalocean.com/community/articles/how-to-install-an-upstream-version-of-node-js-on-ubuntu-12-04 sudo apt-get update sudo apt-get install build-essential sudo apt-get install curl echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc . ~/.bashrc mkdir ~/local mkdir ~/node-latest-install cd ~/node-latest-install curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 ./configure --prefix=~/local (this step takes a while) make install curl https://npmjs.org/install.sh | sh node -v (returns v0.10.21) h2. Installing Nginx http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql sudo apt-get install nginx sudo mkdir /var/cache/nginx sudo chown www-data:www-data /var/cache/nginx sudo mkdir /var/www sudo chown www-data:www-data /var/www vi /etc/nginx/nginx.conf (Delete everything and replace it with the text below.) code.user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m; proxy_temp_path /var/tmp; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; gzip_comp_level 6; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_buffers 16 8k; upstream ghost_upstream { server 127.0.0.1:2368; keepalive 64; } server { listen 80; server_name YOUR_DOMAIN www.YOUR_DOMAIN; if ($host = 'YOUR_DOMAIN' ) { rewrite ^/(.*)$ http://www.YOUR_DOMAIN/$1 permanent; } # location ~ ^/(ghost/signup/) { # rewrite ^/(.*)$ http://YOUR_DOMAIN/ permanent; # } location ~ ^/(img/|css/|lib/|vendor/|fonts/|robots.txt|humans.txt) { root /var/www/core/client/assets; access_log off; expires max; } location ~ ^/(shared/|built/) { root /var/www/core; access_log off; expires max; } location ~ ^/(favicon.ico) { root /var/www/core/shared; access_log off; expires max; } location ~ ^/(content/images/) { root /var/www; access_log off; expires max; } location / { proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_cache one; proxy_cache_key ghost$request_uri$scheme; proxy_pass http://ghost_upstream; } } access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } code.. (Now you need to edit the contents and replace everywhere it says YOUR_DOMAIN with your actual domain like example.com.) (You can now restart nginx:) sudo /etc/init.d/nginx restart h2. Installing and Configuring Ghost http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql http://docs.ghost.org/installation/ http://ghosted.co/install-ghost-digitalocean/ (download the zipped source code) https://ghost.org/download/ (copy .zip file to Digital Ocean server) (install the unzip utility) sudo apt-get install unzip (unzip the ghost source code) unzip ghost-0.3.3.zip npm install --production npm install forever -g vi /var/www/starter.sh (Paste in the script below:) code.#!/bin/sh if [ $(ps aux | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ] then export PATH=/usr/local/bin:$PATH export NODE_ENV=production NODE_ENV=production forever start --sourceDir /var/www index.js >> /var/log/nodelog.txt 2>&1 fi code.. Now enter this command: sudo chmod +x /var/www/starter.sh Next up we want to fix all the permissions: sudo chown -R www-data:www-data /var/www/ Now we need to add a line to your crontab: sudo crontab -e If this is the first time you've used crontab -e then it will ask you which editor to use. I prefer nano for simple edits, but you can choose anything. Place this line at the end of the file and save: @reboot /var/www/starter.sh cp config.js /var/www The Ghost config.js file is up next. Open it up to edit: Edit the lines with "url:" right under development and production declarations replacing the default URL with yours: code.development: { // The url to use when providing links to the site, E.g. in RSS and email. url: 'http:// YOUR_DOMAIN', code.. and code.production: { url: 'http:// YOUR_DOMAIN', code.. (I did not edit the database section of the config.js file, since I'm using the default sqlite.) You are now done. Ghost should be ready to go. Get into the /var/www directory and enter this command: sudo ./starter.sh That should start Ghost, nginx was already running, as was mysql. Visit http://YOUR_DOMAIN and you should see the default page. h2. Notes i unzipped the ghost code in /home/ghost. http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql recommended : q. Download the zip file from your ghost.org account. Get it unzipped and uploaded. Make sure you put the files into /var/www. Now go into /var/www and run these commands: sudo npm install --production sudo npm install mysql sudo npm install forever -g q.. The Ov.org user chose mysql instead of sqlite. Other options for starting and stopping ghost. /home/ghost forever start index.js forever stop index.js