Installing Apache, MySQL, PHP on Ubuntu (Karmic Koala)


Posted on 19th December 2009 by Krow in Setup or Configuration |Tips & Tricks |Ubuntu

, , , , ,

Recently I have been asked by friends, colleagues and even family, how to install and configure a “development or testing” area on their personal computer (localhost). Because I have been asked to do this and each time I end up searching the Internet for guides and help, I thought that it would be a good time to condense what I have found, learned and know to be an ideal setup for a localhost environment.

I have set this post up differently then others that I have seen. I have broken the parts into sections and have linked to those sections so that if you need to come back for help on just one area you can jump to that section/area of the post.

Let me give guidance to those people who run Windows and even Mac OSx:

Windows Users
I would recommend you use a program called XAMPP. XAMPP is a great program and can be installed on all OS platforms (Linux, Mac and Windows). You can download a executable file from XAMPPs Site

Mac OSx Users
I would recommend you use a program called MAMP. MAMP is also a great program for the Mac users. It makes it easy for the users to get things done. You can download the dmg from the MAMP Site

Linux Users
Let’s get started since this post is for you.

Install Apache
Install MySQL
Install PHP

Installing Apache
Everything that I suggest here will be done through terminal. To launch terminal follow these steps:
Application -> Accessories -> Terminal

  1. Once terminal is open type or copy the following command:
    sudo aptitude install apache2
  2. Answer any questions that arise as you see fit. Once the process is finished installing you will need to test that the installation worked. To do this open another tab in your browser and in the address bar type localhost (link to help http://localhost). You should see the text “It works” and that means you have installed Apache2 correctly

If at the end of your installation you get an error or a message inside the terminal window that says “Could not reliably determine the server’s fully qualified domain name, using for ServerName” you can fix this by running the following command in terminal.
gksu gedit /etc/apache2/conf.d/fqdn

You might need to enter your password before the file will open. This command will open a file in gedit (a text editor for Linux).

  • When gedit opens, type “ServerName localhost” (without the quotes) inside the file and click Save.
  • Close the file.

Installing MySQL
Everything in the MySQL section will be done through the terminal window. To launch terminal follow these steps: Application -> Accessories -> Terminal

  1. Once terminal is open type of copy the following command:
    sudo aptitude install mysql-server libapache2-mod-auth-mysql php5-mysql
  2. Near the end of the installation you will be asked to give a user name and password for MySQL
    If you leave the user name blank it will default to “root”

That is it. At this point you should now have MySQL installed an running on your localhost. You can test this by typing mysql in the terminal window. If all is setup correctly you should get a “Welcome to MySQL monitor. Commands end with ; or \g.” and a prompt that says mysql>. From here you can run your mysql commands.

Installing PHP
Everything in the PHP section will be done through the terminal window. To launch a terminal follow these steps: Application -> Accessories -> Terminal

  1. Once your terminal is open type or copy the following command:
    sudo aptitude install php5 php5-common libapache2-mod-php5 php5-gd php5-dev curl libcurl3 libcurl3-dev php5-curl
  2. After everything is installed you will need to restart Apache for the server to see and implement PHP
    sudo /etc/init.d/apache2 restart
  3. You can now test to see if PHP5 is working with Apache. To test if PHP is installed you can create a .php file inside your /var/www/ directory
    sudo gedit /var/www/test.php
  4. The command will open gedit (Linux text editor). Once gedit is open type in the following code:
  5. Open a new tab in your browser and in the address bar type localhost/test.php (link to help http://localhost/test.php)

After running step 5 you should see your PHP Info page. This page will display the settings of your PHP configuration file and what is available via Apache2, MySQL and many other settings you may not care to know about. But the thing is if you see the PHP Information page you have successfully set up PHP5 to work with Apache.

Congratulations, I hope this means you have been able to install one, two or even all three of the items outlined in this post. If everything has worked out correctly you know have a local environment to develop on. Good luck and have fun.

If you have questions please leave a comment.

Installing CakePHP with MAMP


Posted on 29th April 2009 by Krow in Tips & Tricks

, ,

At work we have a few developers that use Mac’s. I have come to like them much more then I used to. So much I bought one for my wife. Still not for me cause I can buy a PC for much cheaper and have grown very happy with Ubuntu.

Any way to the topic at hand I found that helping set up CakePHP on a Mac with MAMP was a bit different and thought I would post here for others to use and for myself to reference if I need to do it again.

These steps are based on the environment we work on and are in some cases preferences too. You can choose to do the steps differently to your setup but for my purposes this has worked great.

  1. Download the latest version of CakePHP (
    At the time of this writing the current version of CakePHP is
  2. Unzip and rename the folder to cake
  3. Go to the “Sites” directory and drop the new cake directory there
  4. Find the path for the CakePHP console (i.e. /Users/username/Sites/cake/cake/console )
  5. Find the path for the php directory (i.e. /Applications/MAMP/bin/php5/bin )
  6. Launch a terminal window
    • Type nano .profile
      • Some alias I prefer to have:
        • alias www=”cd /Users/username/Sites/public_html”
        • alias mysql=”cd /Applications/MAMP/Library/bin/mysql -uroot -p”
      • Enter the following:
        • export PATH=”/Applications/MAMP/bin/php5/bin:/Users/username/Sites/cake/cake/console:$PATH”
        • CTRL X
        • Save
    • Restart your profile
      • . .profile
  7. In your terminal you can now bake
    • Type www
    • This will take you to your web directory
    • Type cake bake project name…

That is it. As I mentioned this post is mostly for a refrence for myself but I hope that it can be a help to others as well. But I would be interested to hear what others have to say and prefer.

CakePHP "The Workshop"

1 comment

Posted on 3rd September 2008 by Krow in Miscellaneous


“The Workshop”
Raleigh, North Carolina

A trip to Raleigh, North Carolina. I haven’t been to Raleigh now for 11 years. But I am excited to have this opportunity to meet with four of the main guys who have made the CakePHP framework. This framework is built for PHP and is a great framework from what I can tell. I have been using CakePHP now for about 6 months and have loved every minute of it since.

It has made my job a lot faster and has made it so that I can develop what a client wants with less bugs and focus on what the client wants not on what is the best way I should build this. Instead the tools and functions are there and all I need to do is plug into the “magical and wonderfullness” of the framework.