How to set up VirtualHost in Ubuntu

My environment is Ubuntu 8.1 Intrepid Ibex. I also written a guide on how to set up virtual hosts in Windows XP or Windows Vista.

0. Introduction

Sometimes, we have multiple projects and we would like to access the Project 1’s website by typing ‘http://project1/’ in the browser address bar. And Project 2 may be at ‘http://project2/’. Virtual hosts are what you need for your development work. This guide requires you to have basic knowledge of Apache. This guide assumes you haven’t done additional configuration to your Apache. You must have already got Apache2 installed.

Also remember that you should always do a backup of every configuration file you change.

1. Add a new host in Ubuntu

You should only be adding new hosts if you want to develop multiples sites in your local computer. Skip this section to go to Section 2 if you just want to add virtual hosts to a remote server.

Type in the following command into your terminal, you need to sudo here: Continue reading “How to set up VirtualHost in Ubuntu”

256 MB probably isn’t enough for me

Keep getting this today. Looks like tweaking the MySQL and Apache processes didn’t really work. Things still go down. I had to do a hard reboot today:

Out of Memory: Kill process 4446 (mysqld) score 124676 and children.
Out of memory: Killed process 4446 (mysqld).
Out of Memory: Kill process 4712 (mysqld) score 53658 and children.
Out of memory: Killed process 4712 (mysqld).
Out of Memory: Kill process 4727 (mysqld) score 53658 and children.
Out of memory: Killed process 4727 (mysqld).
Out of Memory: Kill process 4728 (mysqld) score 53658 and children.
Out of memory: Killed process 4728 (mysqld).
Out of Memory: Kill process 4626 (apache2) score 41595 and children.
Out of memory: Killed process 4626 (apache2).
Out of Memory: Kill process 4613 (apache2) score 41570 and children.
Out of memory: Killed process 4613 (apache2).
Out of Memory: Kill process 4742 (mysqld) score 104640 and children.
Out of memory: Killed process 4742 (mysqld).
Out of Memory: Kill process 4812 (mysqld) score 70759 and children.
Out of memory: Killed process 4812 (mysqld).

This 256 MB VPS runs 2.5 blogs and 1 Python.

Well, it’s time to upgrade to 512 MB I guess. I was intending to up the lighttpd server but perhaps it shall stay asleep but another 2 months. I probably am upgrading to 512 MB coming January.

My blog went down

It was a little sluggish yesterday and I had to do a hard reboot ’cause a soft reboot just hung there. I am running on very limited resources. I have only 256 MB of RAM and every little bit counts. I am on Slicehost by the way.

Previously there wasn’t any problems. It was until recently my friend Daryl have his new blog in my VPS and my new little personal project that’s a little database intensive.

I logged into the web console only to find error messages with MySQL processes. They’re out of memory. I hard rebooted it and tweaked MySQL settings to reduce table caching. Honestly I have no idea what I was doing. People said it worked and I just followed.

That sort of fixed the MySQL problems, but this evening my site become inaccessible again. This time, it was Apache. After reducing the number of Apache servers running, things seem to be doing better.

Here’s my Apache settings, it’s reduced to work on 256 MB RAM:

StartServers 2
MinSpareServers 2
MaxSpareServers 3
MaxClients 70

Then the super cache plugin in WordPress started to misbehave. It just refuse to load anything in the cache after I upgrade super cache. I spent an hour on this one. And I learnt something – when in doubt, just reboot.

Finally did some permenant redirection work

This is long overdue work, just one line, okay two lines of code, but it took me two months to get this done. I always wanted to redirect justrealized.com to i.justrealized.com because some people prefer to type ‘justrealized’ and hit CTRL+Enter on their browsers.

Anyway, this is more of a personal note. To do a permanent redirect using htaccess, you create a file called ‘.htaccess’ with the dot in front and upload it to your Apache web server. Make sure you have the modrewrite enabled. Put the following lines into your .htaccess file and change i.justrealized.com to your new domain.

[code lang=”apache”]RewriteEngine on
RewriteRule (.*) http://i.justrealized.com/$1 [R=301,L][/code]

301 means permanent redirect. There are lots of ways to do permanent redirects but .htaccess is the most straight forward method if you have the mod_rewrite working for you.

[ad#simple]

This redirects all your old URLs to your new domain.

How to enable cURL in PHP for Windows

I’m using Windows Vista and Windows XP. Enabling cURL (Client URL Library) of PHP is really easy and is a matter of uncommenting something only.

Open your php.ini. I use XAMPP for development, XAMPP’s php.ini can be found in C:xamppapachebinphp.ini. You can probably find your copy lurking around there if you use XAMPP.

Do a search of ‘curl’ in the php.ini, there’s probably only one.

extension=php_curl.dll

Uncomment it.

How to set up VirtualHost in XAMPP for Windows

My environment is Windows Vista but these instructions work for Windows XP as well. I also written a guide on how to set up virtual hosts in Ubuntu.

0. Introduction

Sometimes, we have multiple projects and we would like to access the Project 1’s website by typing ‘http://project1/’ in the browser address bar. And Project 2 may be at ‘http://project2/’. This is how we can configure Windows and Apache to do just that. While this guide is written for XAMPP’s Apache, if the instruction applies pretty much to Apache too. You can put your configuration into ‘httpd.conf’.

1. Add a new host in Windows

First go to your hosts file, it is located at C:WindowsSystem32driversetchosts for most people. If you’re using Windows Vista, you need to run command prompt as administrator. Type ‘cmd’ into the search bar and right click on the ‘cmd’ search result to point to ‘Run as administrator’. Continue reading “How to set up VirtualHost in XAMPP for Windows”

How to use sendmail in XAMPP for Windows

The easiest way to start developing in PHP is to get XAMPP, the whole package can even be placed in a flash drive.

0. Objective

To get your PHP scripts to send an email out. This guide assumes you have XAMPP or XAMPP Lite. My environment is Windows Vista. (I use XAMPP Lite by the way)

My XAMPP is placed in C:xampp, so your configuration may be a little different. The files to be modified are sendmail.ini and php.ini.

1. Modify your sendmail.ini

Your sendmail.ini should be located in C:xamppsendmailsendmail.ini. You only need to be concern with 3 variables here: Continue reading “How to use sendmail in XAMPP for Windows”

How much time I spent on reorganizing my computer

Okay, as I was saying, my computer’s getting kinda cluttered and things are just getting harder and harder to find. I use Windows Vista Business, I have multiple copies of Apache, MySQL, Ruby, PHP and other this sort of programs in my computer. If you don’t know what they are, you probably wouldn’t like my blog, maybe you’d be better off at BoingBoing or watching some inspiring videos at TED.

The problem with having multiple copies is that you don’t know when to launch what. Every time I want to – say – launch MySQL, I start thinking really hard which folder should I go into. And when my mind is kinda switching off I often find my mouse pointer moving towards Safari browser icon and visiting Digg.com. Counter-productivity at the very best or worst – you decide.

I always tell myself, okay, next time when I re-setup my computer I’ll do this and that and so on… Each time I re-setup my computer, I always find a flaw with my existing setup. I will restructure my folders again, partition things differently this time. And I always have this optimistic thought that this time I’m really getting it right.

I rarely do. Two months later I would look back at my system thinking of new ways to refine my setup for the future.

Maybe the problem isn’t with me. Maybe the problem is with just the way computers are. All these labyrinth-like hierarchy of folders, it’s more messy than my family tree. Some day, we should kill the ideas of folders, they’re a good way of organizing things but today with people storing more and more files, the concept of folders is hardly a good idea.