Create your website on cloud

2 minute read

Create your website on Virtual Private Server(VPS)

We host our website on cloud VPS, our website based on Jekyll, so we can simply write our pages by Markdown. For the convenience of updating our site, we build Git server on VPS to auto publish it.


  • a VPS (e.g. google cloud VM instance)
  • a domain name (e.g.


  1. ssh login your server(assume the system of your server is Linux);

  2. install Ruby, Jekyll, Git, Nginx;

  3. setup Nginx in /etc/nginx/sites-enabled/default, write:

    # You should look at the following URL's in order to grasp a solid understanding
    # of Nginx configuration files in order to fully unleash the power of Nginx.
    # Generally, you will want to move this file somewhere, and start with a clean
    # file but keep this around for reference. Or just disable in sites-enabled.
    # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
    # Default server configuration
    server {
    	listen 80;
    	listen [::]:80;
    	# your domain name
    	rewrite ^(.*)$  https://$host$1 permanent;  
    server {
    	# listen 80;
    	# listen [::]:80;
    	# SSL configuration for https
    	listen 443 ssl default_server;
    	listen [::]:443 ssl default_server;
    	# put your ssl certificate file under /etc/nginx/cert directory and set here
    	# or you can follow the ssl vendor's instruction
    	# ssl on;	
    	ssl_certificate   cert/xxxxxxxxxxxx.pem;
        ssl_certificate_key  cert/xxxxxxxxxxxx.key;
       	ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
    	# Self signed certs generated by the ssl-cert package
    	# Don't use them in a production server!
    	#include snippets/snakeoil.conf;
    	# your site location
    	root /var/www/mysite;
    	# Add index.php to the list if you are using PHP
    	index index.html index.htm index.nginx-debian.html;
    	# your domain name
    	location / {
    		# First attempt to serve request as file, then
    		# as directory, then fall back to displaying a 404.
    		try_files $uri $uri/ =404;
  4. For https SSL Encrypt, you can use a free SSL provider Let’s Encrypt or Certbot to do it.

  5. setup your git server repository for your site. e.g. /srv/git/website.git. For details, ref Setting Up Git Server

    sudo chgrp -R [remote user name] /srv/git(the dir)
    sudo chmod -R g+rw /srv/git(the dir)
  6. find(or create) file post-receive in dir /srv/git/website.git/hooks' and fill following lines:

    git clone $GIT_REPO $TMP_GIT_CLONE
    sudo JEKYLL_ENV=production bundle exec jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
    rm -Rf $TMP_GIT_CLONE
  7. make sure you VPS port 80&443 are opened;

  8. In site directory on your local computer:

    git remote add server

    then you can use git to update your website, when push your local updates to your server, your site will automatically update.