Hosting jekyll blog site on aws and post by git push | Ram Laxman Yadav

Hosting jekyll blog site on aws and post by git push

Hello There, Hope you are goind great. Today I am gona discuss how to host a jekyll’s blog website on aws and write an new blog post by simply using the git protocol. Here we go:

Create a new machine on aws

You have to create a new machine on aws or may be use existing one. For more detail on creating new machine on aws click here.

# make sure you have ssh access on the machine

Setup for blog site:

  • Install rvm and ruby and bundler.
  • Install jekyll by running gem install jekyll.
  • Install git by running sudo apt-get install git.
  • Install dependencies sudo apt-get install git nodejs ruby ruby1.9.1-dev npm apache2.
  • Change permissions sudo chown -R USER_NAME:USER_NAME /var/www/html.
  • Create a bare repository mkdir blog.git && cd blog.git && git init --bare
  • Create a post receive hook. For this run commands. cp hooks/post-receive.sample hooks/post-receive
  • Write following lines of code inside hooks/post-receive
#!/bin/bash -l

bundle install
cd ..
jekyll build --source $TMP_GIT_CLONE --destination $PUBLIC_WWW
  • Change permission for execution chmod +x post-receive.

Setup on local machine to write posts:

  • Go inside your jekyll blog site’s repository then run the following commands:
  • git init
  • git remote add origin [email protected]_OF_AWS_MACHINE:/home/USER_NAME/blog.git.
  • Add your files by running git add .. You can also use git ignore to manage the unwanted files to be pushed to the server.
  • Commit you changes git commit -m 'YOUR COMMIT MESSAGE'.
  • Pushing to the server git push origin master.

Writing new blogs

  • For writing new blogs you just make a new file inside the posts folder of your blog site and perform git commit and push to pushing your changes to the server.
  • Now go to open http://IP_OF_AWS_MACHINE and you can see your site is live on aws.

Enjoy !!!

Ram Laxman Yadav
Ram Laxman Yadav
Ruby on Rails Developer