How to add www?

Let’s say, you have a website, that is opened by URL: http://ladby.ru. And you want to be able to open it by http://www.ladby.ru also. What should you do? I will describe it now.

In this case www is a subdomain for your website. It is useful usually if you want to have also ftp.ladby.ru for instance. Also it can be useful to redirect from www.ladby.ru so that some users that type your website URL with www will not have any problems accessing it. Here is more information on what is the purpose of the www subdomain.

To achieve this, you should create a CNAME record in your DNS Zone file. Basicly, CNAME record tells where one should be redirected.

I have a record:

Here @ sign means basic address: ladby.ru in this case. So when somebody wants to open ladby.ru, he is redirected to the 78.47.91.3 IP address. A-record returns a 32-bit IPv4 address, most commonly used to map hostnames to an IP address of the host.

Also I have added an important record, which is the core of the trick:

So, when somebody wants to open www subdomain, he is redirected to basic address or ladby.ru.

In my case the final result looks like this:

Also, you should edit your Apache configuration file this way:

It should not be like this:

Hosting multiple web sites on a single Hetzner VPS using Apache virtual hosts

This article is for those, who want to get some understanding of a Web, VPS, Apache. And for those, who want to solve a problem of registering domain names outside Hetzner and hosting multiple web sites on a single Hetzner VPS using Apache virtual hosts, that I solved in some days with a help of lots of experienced people.

Hetzner is a popular German hosting company. They provide, for instance, virtual private servers (VPS). Some hosting companies provide an easy and straightforward way to register any domain names and host them instantly. But Hetzner has some problems with this, since they register only .com, .org and similar domains and do not register .ru, for instance. Also they force you to buy a NameServer Robot for about 30 Euros, that will allow you to edit DNS entries. It is a little bit strange, however, I had to work with this hosting. So, here I will tell you, how I did solve my problems with hosting two different web sites with separate domain names in a Ru zone on a single VPS.

I will describe here, what I did to register a .ru domain name and point it to a folder on the VPS. VPS was already serving for another web site and I had to create another site, which would be working on the same VPS but have a domain name like “http://ladby.ru“.

It is important to understand the architecture of the Web. Domain name is a string like google.com, that corresponds to a single IP address. DNS are servers, that contain these entries of correspondence. They exchange between each other this info. When you register your domain name, you provide registrator with the information, on which DNS you will provide entries for your IP address. When browser tries to open google.com, it goes to a DNS and determines IP address, where it should ask for the site. On this IP address there is a web server like Apache or NGinx, that handles further process.

dns-rev-1

First of all, I registered on a web site http://2domains.ru to register my domain name “http://ladby.ru”, since Hetzner allows you, as I told, to register only .com domains and similar. Then, I registered there this domain name for 1 year and paid about 3$ for this. I had to fill a lot of information about myself including passport data, since Russian government wants to know everything about .ru domain name owners. Nevertheless, I had this domain name available for me in about 10 minutes. What this did allow to me is the possibility to edit DNS for this domain name. What does a DNS (domain name system)? It contains data about correspondence between domain names and IP addresses.

So, the next step was to determine DNS names and their IP addresses on a Hetzner DNS Robot. I just created a new DNS entry using Robot admin panel and got a list of 3 DNS. Then, I determined their IP address using web tools found in Google and filled data on 2domains.ru about these DNS. This is my filled form, but be aware that you will have absolutely different DNS at Hetzner – you should not copy this, you should take your own addresses from your Robot admin panel.

Снимок экрана 2014-06-24 в 16.38.52

The last thing I had to do is to setup Apache virtual hosts to make a single VPS host two web sites. For this purpose, I created a new .conf file in Apache2 folder and a link to it.

Virtual-Host-Multiple-Websites-Ubuntu-13.10-and-Rackspace-Cloud-Server

I did access to the VPS using SSH:

To create conf files in a proper folder I used this snippet:

Apache works this way: it looks at all *.conf files in this folder and uses them to point corresponding web addresses to corresponding folders, where your index.php or index.html is located.

To edit conf file I used Vim:

To reload Apache after editing conf files I used this snippet:

This is my conf file, it can be used as a template:

Notice that UseCanonicalName should be Off.

To create a link to a conf file I used this snippet:

Notice, that a web site is located in a folder /var/www/ladby.ru/public, it is opened also using a proper domain name that I want: http://ladby.ru.

It is important to notice, that a configuration file for Apache should have .conf extension. Also, you have to point ServerName in each config file in this folder, because if you don’t do it, your server will not see your second web site. VirtualDocumentRoot must be correct also.

So, finally what is the result?
1. http://ladby.ru and

This is the second site, that was hosted on the same VPS:
2. http://lovecakes.ru

Open-Source Android and iOS Projects

I highly recommend you to look at popular open-source projects in your field even before you start developing something. Because almost everything you want to create is already created by the community with a very high quality. I understood this a year ago when I discovered Open source in iOS for myself and now I discovered it in Android. In this post I will give you a MUST look list of references and projects.

A list of important and popular open-source projects on GitHub for Android and iOS can be found here:

By best match:

Android

iOS

By most stars:

Android

iOS

By most forks:

Android

iOS

How to use a new model of CocoaPods PodSpec updates

Recently CocoaPods started to use web service to load new PodSpecs.

I will skip a moment, where you need to register your projects to yourself. Basicly, guys that manage CocoaPods have created a web service, that knows, which computer has permissions to which Pod.

But when you have done this, you have to know, how to publish new versions of your Pods. You have to create a tag and push it on a new version as before and use that tag in your pod spec file.

Then you should check your new updated pod spec.

Then you just push your pod spec to a web service. Now you do not have to create one more folder for a new PodSpec file, copy it to your Specs fork and create a pull request. Everything is much simpler!

Here it is important to tell a path to your pod spec file. I use here a dot since my pod spec file is located in the folder, where I am currently in Terminal.
For more information read a blog of CocoaPods project.

If you are asked to register a session first, do this:

In my case: