Monthly Archives: June 2007

Apache 2.0: Setting up a Virtual Host or How to Setup Apache to Host Multiple Websites on a Single Server

Setting up virtual domains in Apache 2.0 is pretty darn easy. Easier then in IIS 6? Well, it requires more typing, but it takes literally less then 5 minutes to get a new domain up on a server.

Before I start, I am making a few assumptions about the operating environment:

  • Ubuntu server is being used, along with Apache 2.0.
  • The user has control over the targeted domain.
  • The user has ‘sudo’ or access to the ‘su’ account.

First, the user needs to point their domain to their server by adding an IP address entry for their domain. For example, this domain has a DNS entry for an IP address pointing to ‘www.alexkuo.info’. Once you have that setup, SSH into your web server.

The first thing I always do is setup a directory to store the files for the website (ex. ‘.html’, .’php’, ‘.jpg’ files). I usually setup a subdirectory in my home directory because I know I already have permissions to read,write, and execute files there.
To do this I type

mkdir websites
cd websites
mkdir www.alexkuo.info

sudo chown www-data:www-data /home/alex/websites

The first three lines create the subdirectory /home/alex/websites/www.alexkuo.info, while the last line sets directory /home/alex/websites and all other subdirectories below it to be readable by the default Apache user.

Next we need to add a virtual host to Apache. You can do this by typing

cd /etc/apache2/sites-available/
sudo touch www.alexkuo.info

The first line navigates to the sites-available directory. Files in here should contain information on the virtual hosts available. Virtual hosts correlate a domain received by Apache and the location of the files to be served for the received domain. The second line creates a file www.alexkuo.info. We will be using this file to configure the virtual host for the domain ‘www.alexkuo.info’.

I usually use ‘vi’ editor to edit text files on servers, and I know ‘vi’ is probably the most user-unfriendly text editor on earth. Instead of using ‘vi’, the user can use any text editor of their choice. In the ‘/etc/apache2/sites-available/’ directory, the user can setup the virtual host ‘www.alexkuo.info’ by typing:

sudo vi www.alexkuo.info

After opening the file, press ‘i’. This will set vi into text editing mode. Afterwards, copy and paste (or type) the following text into the text editor.

<VirtualHost *>
ServerName www.alexkuo.info

DocumentRoot /home/alex/websites/www.alexkuo.info/
ErrorLog /var/log/apache2/error.www.alexkuo.info.log
</VirtualHost>

After the above has been entered, press the [ESC] key and type ‘ZZ’ (or [shift-z][shift-z] in rapid succession). This saves and exits the editor.

This is the most basic configuration you can have for a virtual host. The ‘DocumentRoot’ setting specifies the location of the files to be served when the domain, set by the ‘ServerName’ configuration, is received.

If you haven’t disable the default site, you will need to in order for the server to see the virtual host you created. You can do this by typing:

sudo a2dissite default

After saving the file, you will need to restart Apache2. You need to enable the site and restart the Apache. You can do this by typing the following:

sudo a2ensite www.alexkuo.info
/etc/init.d/apache2 reload

Your site is now setup and live. All that is left is to upload files to your website directory that was created at the beginning of this article. For this website, the directory is ‘/home/alex/websites/www.alexkuo.info/’.

If you would like to setup another site, just repeat the above procedures, except substitute the domain ‘www.alexkuo.info’ with another domain, like ‘subdomain.alexkuo.info’.

If you would like more information on the topic, please consult the following links:

Goodbye to Three Hour Programs

Back in the day, I use to sling code in 2-3 hour blocks, taking nice long breaks in between sessions. This allowed my brain to think about problems deeper and come up with more elegant solutions. One of the reasons is that the house I am in turns into a noise making, hard rocking, garage band around 5 PM when all my roommates come home. Homes with children experience a similar event. In any case, I code late at night or in the mornings when no one is home. In fact, I try and code for as long as I can because I know these periods of peace and quiet don’t last. I guess the 2-3 hour programming sessions will be on ice until ‘quiet time’ becomes the norm again.

New Article

Getting Around Linux: PostgreSQL’s ‘COPY FROM’ and Permissions in the Home Directory

After slinging some code into the dead of night, I ran into a few problems regarding read permissions. One of the tasks I needed to accomplish involved dumping a ‘.csv’ file into a table in a PostgreSQL database. That part was easy, all you have to do is use the ‘COPY FROM’ command in the psql interpreter and voila’, file imported right?

It turns out that the ‘COPY FROM’ command uses a different program that doesn’t have read access to your home directory. This resulted in the following error:

 ERROR:  could not open file "/home/alex/data/widgets.dat" for reading: Permission denied

I tried running chmod 777 on all the files in the ‘/home/alex/data’ directory, but that didn’t work. After some searching, I ran into a forum post that solved my problem. It turns out that you need to give read permissions to directories below the subdirectory you are reading from. You can accomplish this by typing the following:


chmod o+rx /home/alex

Beta Testing Joost

Joost is like YouTube except with complete programming instead of one to three minute clips of random shows and amateur videos, requires a Windows client, smaller selection of content categories, no top ten lists, and with commercials that are spliced randomly throughout shows. The sound and video quality is better than most clips posted on YouTube. Programming isn’t viewed on a schedule like on traditional television, instead, a user searches for programming, just like the search box used on YouTube or Google Video.

Since its almost 3 am over here, I thought to myself that their must be something better to watch on Joost  than on satellite TV. As most people don’t know, I love documentaries. When I’m watching TV, the first channels I surf are the History Channel, Game Play HD, and the Discovery Channel.

I did a few random searches for documentaries, cartoons, and music videos. In terms of pickings, the documentaries list is pretty sparse. All I found were a bunch of amateur videos of ‘famous’ parties around the world and some guy with a show called ‘Death Dealer’ – strangely most of these shows appeared to be from Europe.

Next I searched for cartoons. A few shows popped up, not much variety though. A few included Adult Swim, which I suspect is just reruns of Aqua Team Hunger Force running 24/7, and something called ‘Harveytoons Compilation’. I also saw some  ‘Ren and Stimpy’ and some other random stuff that I never heard of.

My search for music videos also returned some very general search results. Tip for anyone trying to find something to watch, search for specifics. Searching for the term ‘music videos’ won’t return a large search results list. I suspect this is because popularity or views hasn’t been integrated into the search results yet.

So what’s the verdict? Well their’s definitely a huge variety of content, a bunch of random words searched came up with lots of programming. For example, searching for the word ‘jump’ yielded 40 episodes of the Guinness World Records Show. After watching an episode, I still haven’t figured out the relevancy between the show and the word ‘jump’. When compared to YouTube or Google Video, this service definitely could serve as a welcomed channel of distribution for video. But what about Bit Torrent or torrent trackers?

As sad as I care to admit this, torrent trackers still do a better job of offering users content that they’re looking for. Even though Joost is still in beta and legal, the fact that a free semi-legal website serving illegal content does a better job then a multi-million dollar backed service says a lot about how far commercialization needs to go before it will be seen as successful and equivalent to its illegal counter-part. This doesn’t mean I don’t see potential in Joost. The biggest thing Joost offers over YouTube, torrent trackers, or any illegal download service, is better audio/video quality, better search integration, and most of all – instantaneous access. If Joost successfully gets these three elements executed, I think they will be able to make a niche for themselves in the expanding online video market (IPTV, streaming video, whatever you want to call it).

The Conundrums of Hiring Software Developers

Software developers are notorious for having different levels of skill. Along with that are the various types of software developers, stereotypes, preferences for work environments and unfamiliar skill sets. These factors can put any recruiter or HR representative into a conundrum.

A good parallel for recruiting software developers is the NBA draft. The only people who can really tell you which potential draft candidates fit the team and will perform well are either other players who have played with the draft candidates, coaches and scouts who have watched some of these players like hawks for the past months, and to a lesser extent, religious fans who follow the games. When interviewing for a software development position, most interviewers have never even seen a single line of code. Even worse, some interviewers are terrible developers themselves. I say this is worse because bad software developers are like bad basketball players. No one wants them on their team for a reason. Either because they believe in some terrible methods in developing software or their understanding of software development is just plain wrong. (Imagine a guy who thinks the wrong answers are right to all his questions.)

So how do you tell if a software developer is good at all? The same way players make it to the NBA draft. Getting really good at what they do and having something to show for it. Decent developers will have a track record that can be confirmed by third parties such as co-workers, actual working products, and satisfied users. Other software developers can look at a peer’s work and can immediately tell you if their work is poor, decent, excellent, or phenomenal. A comparison can be made between plays made by Michael Jordan and the plays made by the star high school basketball player. Both look pretty good depending on the context, but you need someone who knows what they’re talking about in order to even know the difference between phenomenal and decent in both areas.

I draw a comparison between professional sports players and developers because I believe the skill and talent levels between great players and good players are just as huge in both worlds. A basketball player on a NBA team is pretty damn good compared to 95% of all basketball players in the entire world. A software developer who is of certain (genius? excellent? hacker? I’m not even sure what they call these types.) caliber will produce programs and solve technical problems 95% of software developer can’t even comprehend. People recognize Michael Jordan for his talent and skill because he was much better at basketball then everyone else. People recognize legendary software developers for their similar prowess and skill. Some of these skills are just as publicized in the media. Here’s a few examples:

  • Napster was created by one guy in college because he wanted to share music. Not a whole lot of people can create a peer to peer network single handedly back in the 90’s. The idea was new and the ability to share music as freely and with quality has never been the same.
  • Copying DVDs. This was done thanks to the work of a few guys, even so, it still takes talent to understand how to reverse engineer anti-pirating security schemas. Even though, these guys argue that the protection scheme was pretty weak.
  • On a related note, one guy did crack the HD-DVD encryption scheme himself. Why are either of these last two accomplishments important? It has allowed pirates to copy movies at will. Something that hasn’t been accomplished since the invention of VHS recording but now with higher quality and larger distribution channels.
  • Bit torrent. This took some thinking and understanding of networks in order to implement and was implemented by one person. I’m willing to bet most software developers don’t have a clue how this thing even works.

So what’s the big deal if a person can reverse engineer a multi-million dollar anti-pirating countermeasure or give people the ability to distribute millions of files at a time? These last two inventions have allowed people to enjoy and use their computers in ways that weren’t possible before. Business types call these things innovations which can have the potential to bring in millions of dollars, just like an NBA basketball team that wins a championship equates to millions of more dollars for the owners. This is why recruiting software developers is a big deal, even if most companies don’t know it. Because in the end, you can’t have a great company without great people.