Build Your Own Cloud: Part II, Set Up OwnCloud Server

It is easy to setup an OwnCloud server on Ubuntu.

(1) Install OwnCloud following instructions here:

http://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud

The installation is automatic.  In the process you will be asked for MySQL’s administrative credentials.

After installation, type localhost/owncloud in a browser, you will see the configuration page of OwnCloud.  If you satisfy with SQLite, then you can following the instructions to finish the configuration.  If you want to use MySQL which is recommended by OwnCloud, you shall take the following effects.

(2) Create a MySQL user for OwnCloud and a database for OwnCloud with the following commands

mysql -u root -q # Login MySQL.  Following parts are in mysql.

CREATE USER ‘owncloud’@’localhost’;

SET PASSWORD FOR ‘owncloud’@’localhost’ = password( ‘YourPassWordForMySQL’ );

CREATE DATABASE owncloud;

GRANT ALL ON owncloud.* TO ‘owncloud’@’localhost’;

exit;

(3) In a browser, type localhost/owncloud, and follow configuration instructions on the webpage.

If you choose MySQL, then on the second page, select MySQL and set these parameters:

database user: owncloud

database: owncloud

database password: YourPassWordForMySQL

host: localhost

After successful configuration, if you would like to tighten security, you can take the following effort.

(1) Enforce https.

(1a): Install ssl certificate for your apache server.  Below are useful informaiton:

https://www.openssl.org/docs/HOWTO/certificates.txt

https://support.godaddy.com/help/article/5238/installing-an-ssl-certificate-in-apache-centos

(1b) Enforce https in OwnCloud’s administrative panel.

(2) In your router, remove port 80 from your “Virtual Server” for port forwarding.

(3) In your router, enable MAC filtering, only allowing those devices that you permit to use the cloud.

Build Your Own Cloud: Part I, Set Up Your Domain Name

In this article, we outline how to build your own cloud with open source software OwnCloud (https://owncloud.org).  Two components are needed to run a OwnCloud server with your home computer:

(1) A static IP or a domain name which dynamically maps to the IP your ISP assigns to you.

(2) A computer running the OwnCloud server.

The static IP or the dynamically mapped domain name is the “postal address” to find your server on the internet.  Holding a static IP is not cheap, so it is more interesting to use a dynamic IP with a domain name.  You need these:

(a)  Buy a domain name, for example YourDomain.com, from domain registrars, such as GoDaddy, NameCheap or Google.  This usually cost about $12 a year.  With a domain name, you can add  subdomains as you like, for example cloud.YourDomain.com, or mail.YourDomain.com

Here YourDomain.com is a primary domain, and cloud.YourDomain.com is a secondary domain.  Some registrars directly sell secondary domains attached to their specified primary domains at a lower price, such as YourSecondaryDomain.TheirPrimaryDomain.com.  I do not quite like this, because TheirPrimaryDomain might be uneasy to remmember.  I prefer to have my own primary domain, with which I can extend many subdomains for many different services.

Let us assume that you decide to use cloud.YourDomain.com, and you are going to run OwnCloud server on a computer YourServer.

(b)  Use a free or buy a Dynamic DNS host to dynamically map could.YourDomain.com to the IP your ISP assigns to you.  A domain name is like the name of a company and an IP address is its “postal address”.  Because IPs are relatively scarce, most ISPs circulate IPs around its customers.  Each time an active user may receive a different IP.  When you type a domain name in your brower, your computer first asks some domain name servers to translate it to its IP.  As your IP dynamically changes, you need a domain name sever to track its change.

A Dynamic DNS tracks the change of your IP by receiving reports from your home computer or router.  If you directly connect YourServer to the internet, then you can install the client software provided by your Dynamic DNS provider on YourServer. It will automatically report changes of your IP.  If you run YourServer behind a rourter, then you shall check whether its dynamic IP reporting function is compatible with the Dynamic DNS server.  For example, I could not figure out how to make my dlink router report to namecheap.

By the way, if you use a dlink router, you can use http://www.dlinkddns.com to map one secondary domain in the format of YourSecondaryDomain.dlinkddns.com for free.  I will discuss how to utilize this.

(c) If YourServer is behind a router, then forward ports 80 and/or 443 from the router to YourServer.  OwnCloud use port 80 to run its http interface and 443 its https interface.  As cloud.YourDomain.com is mapped to your router, connection to cloud.YourDomain.com will be directed to your router.  Thus, you need to tell your router to relay requests to ports 80/443 to YourServer.  If you use a dlink router, you can do it with the “Virtual Server” function.

My Example:

(1) I bought MyDomain.com from 1and1.  By the way, they suck, I will definitely transfer to another registrar after finishing my one year term.

(2) I added subdomain cloud.MyDomain.com for my cloud service.

(3) I tried to use namecheap’s freeDNS, so I changed the name server associated with MyDomain.com to namecheaper.

(4) Unfortunately, my dlink router is not compatible with namecheap’s freeDNS, so I utilized http://www.dlinkddns.com’s free dynamic DNS service for dlink customers.

(4a) I got a free secondary domain name MyCloud.dlinkddns.com, and setup my dlink to report its IP to http://www.dlinkddns.com.  dlinkddns only supports secondary domains in the format xxxx.dlinkddns.com.

(4b)  So fare I had two domain names: cloud.MyDomain.com which I preferred and MyCloud.dlinkddns.com which I used for its free dynamic DNS. How to combine them?  I set the  cname of cloud.MyDomain.com to MyCloud.dlinkddns.com.

(5) I forwarded ports 80/433 from my router to MyServer inside my LAN.

The mapping chain of cloud.MyDomain.com is:

cloud.MyDomain.com (via namecheap’s cname map) ->

MyCloud.dlinkddns.com (via http://www.dlinkddns.com’s dynamic DNS) ->

MyRouter (via its Virtual Server function) ->

MyServer

Please note that it is unnecessary to use namecheap’s freeDNS here.  I can just use 1and’s cname service, but I dislike 1and1 so much that I avoid their services as much as possible.

Some suggestions:

Choosing a good registrar will save you a lot of trouble.  Google looks to be a good provider.  They charge $12 for a year, with private registration and more importantly it includes dynamic DNS!

namecheap is good, but unfortunately they are incompatible with my dlink router.

http://dyn.com has stopped its free service, so you have to go to alternatives.

GoDaddy is popular, but they do not include dynamic DNS.

Insert Latex to Inkscape in Windows

First, install the following software:

  1. Miktex
  2. Ghost script
  3. GSView
  4. Pstoedit

Second, add miktext, gs and pstoedit to the environmental variable PATH:

For example, in order to add pstoedit to the path:

Computer > Properties > Advanced > Environment Variables > PATH > Edit 

Add the following:

;C:\Program Files (x86)\pstoedit;

Don’t forget semi colons.

Reference:

http://stackoverflow.com/questions/11793601/insert-latex-to-inkscape-in-windows

Multiple Streams Write to the Same File with GNU C Library

Types of Channels

(1) You can have multiple file descriptors and streams (let’s call both streams and descriptors “channels” for short) connected to the same file. [1]

(2) There are two cases to consider: linked channels that share a single file position value, and independent channels that have their own file positions. [1]

(3) It’s impossible for two channels to have separate file pointers for a file that doesn’t support random access. Thus, channels for reading or writing such files are always linked, never independent. [2]

(4) Append-type channels are also always linked. For these channels, follow the rules for linked channels. [2]

Independent Channels

(1) You should clean an output stream after use, before doing anything else that might read or write from the same part of the file. [2]

This statement implies that it is OK for multiple independent channels each write to different parts of the same file at the same time as long as they clean themselves after use.

(2) You should clean an input stream before reading data that may have been modified using an independent channel. Otherwise, you might read obsolete data that had been in the stream’s buffer. [2]

Reference:

[1] http://www.gnu.org/software/libc/manual/html_node/Stream_002fDescriptor-Precautions.html#Stream_002fDescriptor-Precautions

[2] http://www.gnu.org/software/libc/manual/html_node/Independent-Channels.html#Independent-Channels