Skip to main content

Your OwnCloud Server on your Hyper-V – scrap dropbox

Do you want to create your own owncloud server with LVM support and easy updates through packages? Here is an easy guide (Note that Azure VMs do not come with LVM preinstalled on Ubuntu, so this guide is only for on-premise Hyper-V as far as the extension of the disk goes):

Collect information :
External IP to be used :
Internal IP to be used : 192.168.x.x
Ports to be forwarded to the LAN : 80,443,10000 (10000 for webmin administration)
Certificate to be used for secure communication :
Subdomain to be used for access :
Username : adminusername
Password :
Mysql Root Password :
owncloud username : adminusername
owncloud password :
owncloud mariadb database : owncloud
owncloud mariadb username : adminusername
owncloud mariadb password :
Download Software :

Install :
Create a new HyperV Virtual Machine named :
Install Ubuntu using the above ISO and configuring networking and usernames/password as above using the installation
wizard. Make sure to select the OpenSSH server in the end. (all the other steps just hit enter)
Connect to port 22 (ssh) on the server using putty or similar.
Run the following commands :
sudo -s
nano /etc/apt/sources.list

#Add the following lines in the end of the file :
deb sarge contrib
deb sarge contrib
#Hit ctrl+O
#Hit ctrl+X
cd /root
apt-key add jcameron-key.asc
apt-get update
apt-get install webmin
cd /tmp
sudo apt-key add – < Release.key
sudo sh -c “echo ‘deb /’ >>
apt-get update
apt-get install owncloud
apt-get install mariadb-server
mysql -u root -p

#On the mariadb prompt enter :
GRANT ALL ON owncloud.* to ‘owncloud’@’localhost’ IDENTIFIED BY ‘ENTER REQUIRED PASSWORD HERE‘;
sudo apt-get update && sudo apt-get upgrade
sudo apt-get update && sudo apt-get install owncloud
echo “<meta http-equiv=’refresh’ content=’0;url=/owncloud’ />” > /var/www/html/index.html

Go to http://ipaddress
Enter the credentials for the first user as chosen in the collection section of this article.
Where it says Storage and database, select : MySQL/MariaDB
Enter database user,password, and database name as above, leave localhost in the end.
Finish setup

You are done. Go login


Adding an extra 1 TB disk 

Extend the disk by attaching new VHDs
Shutdown the VM
Add an extra disk using hyperv manager (a new scsi disk of size : 1 TB)

#Login to ssh using putty
echo “- – -” > /sys/class/scsi_host/host0/scan
fdisk -l
#Identify the disk , for example it will be /dev/sdb. Then continue (this tutorial assumes sdb)
fdisk /dev/sdb
hit enter
hit enter
hit enter
pvcreate /dev/sdb1
#note the volume name thing. Mine looks like cloud-vg. use this for next steps
vgextend cloud-vg /dev/sdb1
lvextend /dev/cloud-vg/root /dev/sdb1
resize2fs /dev/cloud-vg/root


Create a 1 TB Linux virtual Machine in Azure

Azure is great, and the greatest thing is that you can run tiny Linux virtual machines and attach lots of cheap hdd space on them. You will only pay what you use of this extra space.

Here is how you can create a LINUX virtual machine in the Azure, and then attach an extra 1TB disk on to it. After that you can install owncloud or whatever and replace this 10$/month dropbox subscription you had.

  1. Login to your Azure
  2. Create a new Ubuntu 15 (Vivid) VM on any tier
  3. In the Azure dashboard for the VM, attach a new disk with 1023GB
  4. SSH to your VM on port 22 and authenticate
  5. Run : sudo fdisk /dev/sdc
  6. Type : n
  7. Type : p
  8. Hit : Enter
  9. Hit : Enter
  10. Type : w
  11. Run sudo mkfs -t ext4 /dev/sdc1
  12. Run sudo mkdir /data
  13. Run sudo mount -t ext4 dev/sdc1 /data

You know have the new disk in the /data folder for use 🙂

You can verify by running : lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

RTMP HLS nginx php Server – The easy way

Tired of paying for Wowza media server? Unreal media server?
Tired of trying to find a decent tutorial on how to build your own nginx rtmp server with php and hls support?
UPG.GR has the solution for you with a few easy steps (as usual)
*Note that a referral link to digital ocean is included in this article that will grant you 10$ of credit to try for free with no obligations

If you are an advanced linux user and have your own linux box, just run the following command on any Ubuntu and your done! : curl -sL | sudo bash –

Step 1
Go to digital ocean and get a free account with 10$ credits (to use for a month)


Step 2

Enter your email and select a password



Step 3

Activate your account and login to get your free credit



Step 4

Create a new droplet


Step 5

Select the 10$ a month droplet. This will be enough for testing and for about 100 concurrent users. Enter the subdomain of a domain you control For example if you have a domain enter “”. If you do not have domain just enter there whatever and you will access your server with the ip you will be provided.


Step 6

Select a country near you.


Step 7

Select your favorite UBUNTU distro. Watch this space for a Centos tutorial – request it in the comments and I ll do it for you.


Step 8

Create droplet :


Step 9

Wait for your droplet to be created


Step 10

Check your email for your login credentials


Step 11

In the meantime go your registra or dns server to map the subdomain you chose to the ip of the server you got in your email. In my example I am using the free tier of cloudflare to manage my dns (


Step 12

Go back to digital ocean and start the console (or just putty to the ip on port 22 and authenticate)





Step 13

Login using the credentials you are provided in your email


Step 14

Enter “sudo -s”


Step 15

Enter “sudo apt-get install curl -y”

Enter “curl -sL | sudo bash -”


Step 16

Your server is up! you can test it on the address you specified. Port 80 and 1935 is open. port 80 for the player port 1935 for the streaming. You may stream using Adobe Media Encoder (free). Remember to use the h.264 codec and not the default VP6 !


Connect and start streaming

Step 17

Test your streamer by visiting the main interface on the subdomain you defined or the ip address you were provided. I have prepared 5 streams. stream1,stream2,stream3,stream4,stream518

Step 18

Review my github projects where you can find all the source code for this project.

There are 3 projects :   –  Automation – Fork of the latest working nginx server (1.9.2) – Latest fork of the rtmp module for nginx

You can edit the nginx.conf to suit you needs at : /usr/local/nginx/conf/nginx.conf

You can find the html files that show the web interface at : /usr/local/nginx/html


To do :

Web administration for nginx.conf options
Ftp server to edit the php files

Please comment here to encourage me to continue with this project.

C Function to Validate ISO 8601 Date Formats Using ‘strptime’

Here’s a demonstration of how to use strptime and a list of format strings to validate, for example, a supplied ISO 8601 date in C or C++. You can play with the code below over at It’s not an extensive list of all ISO 8601 dates, but these are the ones that work within a MySQL query. One improvement that could be made is to handle timezones in datetime strings like ’2010-01-01T01:01:01-7:00′ and potentially micro seconds (if possible).

This is also a good demonstration for how to easily loop through all elements in an array of undefined size in C.

#define _GNU_SOURCE
#include <stdio.h>
#include <time.h>
#include <string.h>

static int
is_valid_iso8601_date_value(char *in)
    struct tm result;
    char **f;
    char *ret;
    char *formats[] = {
        "%Y-%m-%d %T",
        "%y-%m-%d %T",
        "%Y-%m-%d %TZ",
        "%y-%m-%d %TZ",
        "%Y%m%d %TZ",
        "%y%m%d %TZ",

    memset(&result, 0, sizeof(result));

    for (f = formats; f && *f; f++)
        ret = strptime(in, *f, &result);
        if (ret && *ret == '')
            return 1;

    return 0;

int main(void) {
	char date_str[] = "2010-01-01T01:01:01Z";
    if (is_valid_iso8601_date_value(date_str))
    	printf("%s is a valid iso8601 date!", date_str);
        return 0;
    	printf("%s is not a valid iso8601 date!", date_str);
		return 1;

Using ‘shopt’ To Adjust Bash Terminal Number Columns After Resizing Window

This solved a long time frustration I had within PuTTY in that when changing the window size, the terminal columns get all messed up and you get some pretty strange behavior (as seen in this blog post). The solution is to use shopt with the checkwinsize option. This will make sure that your bash terminal will always have the correct number of columns.

shopt -s checkwinsize

After throwing this into my ~/.bashrc file (or ~/.bash_profile, if you prefer), my frustration is gone! Whew!

Check out the man page or this page for more information.

Use CDPATH to Quickly Change Directories

You can create a shortcut to frequently accessed directories by adding them to the CDPATH environment variable.  So, say I frequently access /var/www/html/.  Instead of typing cd /var/www/html, I can add /var/www/ to CDPATH and then I only have to type cd html.

Open ~/.bashrc (or ~/.bash_profile) and add the following line with your frequently used directories separated with a colon (similar to PATH variable).

export CDPATH=$CDPATH:/var/www/

Here’s an example usage:

dhildreth@hostname:~> export CDPATH=$CDPATH:/var/www/
dhildreth@hostname:~> cd html

There’s one caveat to using this that I’ve ran into in the past: if you are working with Makefiles and building c/c++ apps, this can potentially confuse the Makefile script. So, if you suddenly can’t build your project after adding this variable, try removing it.

A Loving Copyright Notice (With Interesting Date)

I just came across this loving copyright notice in a file at work. For one thing, I enjoyed the content, but then it got me wondering if it was inspired by 9-11. The more I thought about it, the more I enjoyed the content.

** 2001 September 15
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.

Attn Subscribers: Google Reader Being Shutdown

Google announced March 13th that it’s going through some more spring cleaning which includes Google Reader (see and I’d like to remind my subscribers, of which 90% or so are using Reader or iGoogle, may need to resubscribe or transfer their subscription to iGoogle or another feed reader. You should be able to click the RSS Feed link and choose an RSS reader. Thanks for your continued support!

Tutorial: Installing Django on Shared Hosting Service Such as

This guide will walk you through how to install and run Django on a shared host such as Bluehost. Because I use Bluehost, I was able to verify the steps you see below, but you might need to modify some of the steps to work with your specific host. The whole thing should take less than 10 minutes. If I’ve done my job right, you should be able to copy/paste multiple lines to run all commands in a block as if it were a script. If you feel more comfortable, you can run each command line by line. Let’s get to it…

Step 1: Installing Python 2.7

This step is for those of you who have an older installation of Python on your webhost. In the case of Bluehost (as of 12/6/2012), the version that is installed is 2.6.6. If you have version 2.7.0 and up (but not including version 3.0), then you can skip this step. Otherwise, follow along (you should be able to copy/paste this entire block into the terminal to run it all at once):

cd ~
mkdir python27
tar xf Python-2.7.3.tgz
cd Python-2.7.3/
./configure -prefix=$HOME/python27/ --enable-unicode=ucs4
make && make install
mv ~/python27/bin/python ~/python27/bin/python27
echo "PATH=$PATH:$HOME/python27/bin" >> ~/.bashrc
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc
echo "export LANG=en_US.UTF-8" >> ~/.bashrc
. ~/.bashrc

At this point, you should be able to run which python27 successfully like this:

# which python27

Step 2: Installing SetupTools and PIP

Now that Python 2.7 has been installed, we’ll need to install setuptools and pip (you should be able to copy/paste this entire block into the terminal to run it all at once):

tar xf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python27 install
cd ~
tar xf pip-1.1.tar.gz
cd pip-1.1
python27 install

At this point, you should be able to run which pip successfully like this:

# which pip

Step 3: Use pip to Install Modules

We’re going to install MySQL-python, flup, and Django using pip (Note: If you plan on using PosgreSQL, you’ll need to install psycopg2):

pip install Django MySQL-python flup #psycopg2

At this point, you should be able to run which successfully like this:

# which

Step 4: Setup an Environment for the Project

I’m going to name the project ‘myproject’. When you go to create your own, you’ll want to replace anything called ‘myproject’ with the project name of your choice (you should be able to copy/paste this entire block into the terminal to run it all at once):

mkdir ~/public_html/myproject
cd ~/public_html/myproject

cat > myproject.fcgi << EOF
import sys, os
project_name = "myproject"

# Add a custom Python path.
sys.path.insert(0, os.path.expanduser("~") + "/python27")
sys.path.insert(13, os.getcwd() + "/" + project_name)

os.environ['DJANGO_SETTINGS_MODULE'] = project_name + '.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

cat > .htaccess << EOF
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ myproject.fcgi/$1 [QSA,L]

chmod 0755 myproject.fcgi

Step 4: Create the Django Project

Lastly, we’re going to use django-admin to start our project called ‘myproject’ making sure to be in the correct directory first:

cd ~/public_html/myproject/ startproject myproject

Now, visit your website at http://mydomain/myproject and you should see the Django start page! Have fun with it.

A final note: If you want to use the admin pages, you’ll need to follow a few more steps to get the page to show up properly with css, js, and images (you’ll need to replace mydomainname with your actual domain name).

ln -s $HOME/python27/lib/python2.7/site-packages/django/contrib/admin/static $HOME/public_html/myproject/static
sed -i "s/^STATIC_ROOT = ''/STATIC_ROOT = 'admin'/g" $HOME/public_html/myproject/myproject/myproject/
sed -i "s/^STATIC_URL = ''/STATIC_URL = ''/g" $HOME/public_html/myproject/myproject/myproject/

Sources: Simply Argh Blog

Handy Terminal Keyboard Shortcuts

Put these into your “Terminal Guru” belt and be more productive!

Cursor Movement Control
Ctrl-a: Move cursor to the start of a line
Ctrl-e: Move cursor to the end of a line
Ctrl-Left/Right: Navigate word by word (may not work in all terminals)

Modify Text
Ctrl-w: Delete the whole word to the left of the cursor
Ctrl-k: Erase to end of line
Ctrl-u: Erase to beginning of line

Scrolling/Buffer Control
Shift-PageUp/PageDown: Scroll through current buffer
Ctrl-s: Pause terminal output (program will keep running)
Ctrl-q: Release terminal output (after being paused)
Ctrl-l: Clears the screen. Use this instead of the clear command.

Ctrl-r: Search the history (enter to run the command once found)

Bonus Tip: Use ‘!!’ command to run last command and ‘!com’ to run the last command starting with ‘com’.

Process Control
Ctrl-d: Exit
Ctrl-c: Kill the current process
Ctrl-z: Put the current process in the background (fg will restore it)

Are there any keyboard shortcuts that you can’t live without? Tell us about them in the comments below.