Access Jekyll server running inside vagrant box

By default Jekyll listens for request coming from localhost only.

We have to configure Jekyll to accept incoming requests outside of localhost.

Use command provided below to start Jekyll server :

$ Jekyll server --watch --host 0.0.0.0

The trick here is to use –host 0.0.0.0 which tell Jekyll to accept all incoming connections.

Hope this helps someone hours of headbanging.

Vagrant syntax for adding existing local box

Syntax provided below can be used on windows to add existing local vagrant boxes.

vagrant box add custom32 file:///f://Vagrant//precise32.box

In the above command custom32 is the name for the vagrant box and “file:///f://Vagrant//precise32.box” is the locally available box. This box was downloaded from internet and placed locally on f drives Vagrant folder.

Also see the screenshot below:

vagrant box add, syntax to add local vagrant boxes

Syntax to add vagrant boxes

[Solved] Error executing git commit in phpstorm

I thought Git and Phpstorm would work out of the box with minimal configuration. I pointed Git.exe in phpstorm and tried committing a file. To my surprise, I got the following error always.

example is taken from web:

"Error executing git commit --only -F /private/var/folders/bs/zfry67p51_gflf6hqgzplv2xt80189/T/git-commit-msg-5921808149812071312.txt --author=dsedlacek -- web/js/definitions/jquery.d.ts web/js/libs/handlebars-v1.3.0.js web/css/icon...."

And after poking around for a while. I kept git.exe in windows global PATH variable and Phpstorm started working smoothly with Git :).

Solution: Set full path to git.exe to windows environment PATH variable.

Right click on computer > Properties > Advanced system settings > Goto advanced tab then click on “environment variables” > In system variables find the PATH variable edit it and at the end put semicolon and then append the full path to git.exe.

Hope this helps the needy soul :)

Walkthrough on remote access to Ubuntu14.04

I often access my ubuntu machine remotely and today I will be describing how I setup my machine to access it remotely from anywhere through internet. This is not a step by step guide rather it’s a kind of walkthrough and giving overview on how I knitted each bits and pieces to get the job done. To understand this post, you will need to have basic understanding of IP addresses, basic understanding on router, port forwarding, installing/uninstalling applications on Ubuntu, webserver for hosting php files, basic understanding of cron jobs on linux.

Let’s get to the point, at first I installed xrdp on my Ubuntu box and then installed xfce4. I found this http://www.tweaking4all.com/software/linux-software/use-xrdp-remote-access-ubuntu-14-04/ link very helpful. I won’t explain how to install xrdp and xfce4. Follow the link and you will have xrdp and xfce4 installed at the end of that post.

Now the next part is to configure the router. At first enable the remote management port in your router. This instruction differ from router to router so find the instruction that suits to your case. After that forward the port 3389 to your local network IP (for e.g. 192.168.0.10). This local IP will be generally one assigned by your router to your local machine, if DHCP is enabled in your router otherwise you’ll have to manually assign static IP to your local machine. Now the most important part is to get dynamic IP. This dynamic IP is what other users on internet will use to access your computer directly. This dynamic IP varies everytime you make connections to your ISP. Each time your router connects to ISP, each time it gets a new IP assigned by ISP so knowing this IP is crucial part. this IP will be used to access your router remotely and then configure port forwarding to the local machine. I am using a php script to get the dynamic IP. I found a little PHP snippet that does the job of finding the ISP assigned IP address (WAN IP).

<?php
//Filename : ip.php

$externalContent = file_get_contents('http://checkip.dyndns.com/');
preg_match('/Current IP Address: ([\[\]:.[0-9a-fA-F]+)</', $externalContent, $m);
$externalIp = $m[1];
$date = new DateTime();
echo "Last updated :". $date->format("m/d/Y H:i:s a");
echo PHP_EOL;
echo "WAN IP: ".$externalIp;
;?>

The output is

Last updated :10/17/2014 21:30:02 pm
WAN IP: 182.93.64.253

Save the above php snippet in ip.php and put it inside htdocs of your local webserver. In my case, I have kept ip.php file in my webserver’s test folder accessible at http://test/ip.php.

I have set cron job in my machine that runs ip.php file and saves the out on wan.txt file. I have another shell script (ftp.sh) which uploads this wan.txt file to my personal web-space. Now, this uploaded wan.txt is accessible from internet at (http://www.samundra.com.np/wan/wan.txt). I am now able to get the dynamic address assigned to my machine everytime. Below is the cronjob settings and ftp.sh contents.

ftp.sh

#!/bin/bash
echo "Uploading ip.txt via ftp"
HOST=ftp.yourdomain.com
USER=user@yourdomain.com
PASS="XXXXX"
ftp -inv $HOST << EOF
user $USER $PASS
put "wan.txt" "wan.txt"
bye

Put the appropriate settings on HOST, USER, PASS and then save the ftp.sh and put in the same location where you have kept ip.php.

Cronjob settings

*/5 * * * * /usr/bin/wget -q -O wan.txt http://test/ip.php
*/5 * * * * /var/www/test/ftp.sh

Those were all, what I did for getting my machine to internet. I have configured various services on my machine and use them on regular basis using remote access. When you are exposing your machines to the wild you need to take precautions and use tight security measures which I haven't mentioned here. Hope this sharing helps someone out there.

Let me know your comments and feedbacks. I will try to answer your queries as soon as possible.