Hacks and Hints TechieVarta

Icon

Another Techie Varta

Archive for the ‘linux’ Category


Create a full featured web/blog host at your home: Part 2

Thursday, October 25th, 2007

Part 1

As promised here is the part 2 of the post.

Setting up Web Server

The next task is to setup your web server. There are several servers you can choose. My favorite is Apache. It comes bundled with most Linux distributions. You probably want to setup the apache server as a virtual host. To setup the virtual server, fire up your favorite editor to configure apache configuration and add something like the following:

<VirtualHost  *:80>
	DocumentRoot /srv/www/htdocs
	ServerName example.com
	ServerAdmin root@localhost
	<Directory /srv/www/htdocs>
		AllowOverride None
		Order allow,den
		Allow from all
	</Directory>
	CustomLog /var/log/apache2/example.log
</VirtualHost>

Restart apache by doing something like /etc/init.d/apache restart. If you took my earlier warning about security seriously, you would have firewall on your server blocking all accesses to your web server. Use your favorite firewall management tool for the server to open hole through server firewall. Suse’s yast makes this process relatively straightforward. I am sure other distributions have something similar.

Edit /etc/hosts on the web server machine and add a host entry for the web server’s IP address as your machine’s NATed IP address. This step is not absolutely essential but it makes life a lot simpler. Fire up firefox on the Linux machine and make sure you can access http://<your-machine’s name>/. If you try to access the same web page from another machine in your network, this is probably very slow. That is because the DNS is resolving your machine’s the hostname as external IP address of your NAT box and the packets are not directly going to your Linux machine. If you have this problem open /etc/hosts on Linux and c:\windows\system32\drivers\etc\hosts on Windows machine and add an entry with webhosts name and its NATed IP address. The entry will look something like:

 192.168.32.8    example.com

At this time you should be able to go to the newly configured host and access the web site. You are now ready to configure blog software.

Setting up Blog Software

Now it is time to setup you blog software. After evaluating several blog software, I decided to use WordPress. I will strongly recommend WordPress to nearly everyone trying to host their blog site. It is easy to administer. There is a very strong community out there. You can easily find plugin for almost anything you want to do. WordPress is based on PHP so make sure you have PHP installed before you start. WordPress also has dependency on MySql make sure you have MySql installed. The next step is to create MySql user.

To create the MySql user do the following:

>mysql -u root -p

Password: <enter mysql password>

mysql>create <db-name>

mysql>use <db-name>

mysql>GRANT ALL PRIVILEGES ON *.* TO

        '<user>'@'localhost' IDENTIFIED BY

        '<db-pass>' WITH GRANT OPTION;

Note down the db-user and db-pass entered in this process.

You are now ready to configure and install the WordPress. Download WordPress and unzip it at a place where your webserver can serve. In the wordpress home directory, there is a file wp-config-sample.php. Copy it to wp-config.php. Edit this file to provide DB name, DB username and DB password.

Fire your Web Browser and point it to the blog’s home directory. Follow on screen direction to complete the WordPress install. You are all set. Drop me a word if you have problem installing.

Happy blogging.

Next time essential WordPress plugins.

Create a full featured web/blog host at your home: Part 1

Wednesday, October 24th, 2007

If you are wondering why will I want to do this. Just scroll down to the FAQ section.

WARNING: Running a server at home is always a security risk. So be careful.

The blog host setup will involve network setup, actual host setup, web server setup, and blog software setup.

Network Setup

You will need a good Internet connection. A cable or FIOS connection will offer good enough bandwidth for your site. In most cases the blog host will share the Internet connection with other machines. You will need a good NAT box. Linksys and Netgear both make lots of good affordable NAT boxes. Most Install the NAT box and connect your Linux machine to the NAT box. If you do not know how to configure NAT box, just Google for it or look at the NAT’s manual.

Next you will need a public hostname so that your friends can find you. I use DynDNS. They offer free web host name in 10s of domains. You may want to sign up with a service which is supported by your NAT box. Sign up with dynamic DNS provider and configure your NAT box with the DNS information. In most cases DNS takes immediate effect however in some cases DNS entries can take up to 72 hours to propagate through the network.

Open a command prompt and type > nslookup <your dns name>. If this resolves to the public IP address of your NAT box, you are all set with DNS configuration.

Web/Blog Host Configuration

For web/blog host you will need a reasonable machine. If you have an old reasonably powered P4 machine, that will be a good candidate. Install an Operating system on the machine. Linux is most suitable web host. It offers good mix security and performance. Unlike Windows most Linux distributions work on old machines lying in your closet. You can use any decent Linux distribution on this machine. I use OpenSuse. Since this machine will be externally accessible update any security patches. Also, configure rather restrictive iptables based firewall.

Next you will need to configure port forwarding on your NAT box. Logon on to your Linux machine and type “ip addr” to get IP the address assigned to your machine. Now logon to admin interface of the NAT box. Find the place where you can configure port forwarding. Configure it to forward port 80 to the IP address of your Linux machine.

In part 2 I will go over the details of Web Server and Blog software configuration.

FAQ

Why do you want to create a website at your home when there are so many other options?

Because I can. Because it is fun. Because I have full control over the software which runs the site. Because it serves my intellect.

Will this slow down your home network?
For most average users, it is not a big deal. Most cable service providers offer you enough bandwidth to run a reasonable site at home. If your site really gets busy and gets too much traffic, you may have to move site to ISP. But, at that time you can also become part of Adsense and earn some money. Most users will never reach that level of usage.

My Choice of Linux Distribution - OpenSuse 10.3 Review

Tuesday, October 23rd, 2007

As I was setting up my blog host I had a critical decision to take. Which OS? I have been using Linux for more then a decade now. I remember the days in India when I had to download 13 floppies of Slackware at 9.6Kbps to install Linux. I have used RHEL, Kubuntu, Fedora Core, Mandriva. But, since I was installing a new machine for this blog, I decided to experiment with OpenSuse which I had never used in past.

I must admit I am hooked. Following OpenSuse instructions I decided to perform a network installation. The installation procedure worked ok although it can use some improvements:

  1. I wish the installer tested a couple of mirrors and automatically selected the mirror to use
  2. I wish that the installer asked all the questions in advance and started the installatio rather then stopping during the installation process to ask the question. That way I could start installation process, go for a drive and come back to a brand new OpenSuse desktop

In most Linux and Windows machines finding the any program to run from Start menu has been a pain. The Suse menu system on the other hand is clean and nicely categorized. I like the multi-tab menu interface a lot.

At the top of it yast is great. I was able to find new packages easily (although package manager is slow to start), the firewall configuration is easy and intuitive. I tried configuration creating virtual host using the yast interface without much luck.

But even with its deficiency the OpenSuse is superior to Kubuntu, RHEL, and Mandrive. My next favorite is Ubuntu which I run on my laptop. That is for another day.