Also visit my Company Blog at ansustechnologies.com
Follow productzen on Twitter

Tuesday, September 1, 2009

Installing LAMP for Web Development

Recently I started on building a social networking platform to experiment on Open Social and Off the shelf products that allow users to create their own social networking websites.
Looking around the landscape, I found every body is using Linux,Apache,MySQL,PHP as their choice platform, language and tools. So I downloaded Ubuntu 9.04 and planned to install my social networking website using LAMP infrastructure on Ubuntu. Later I plan to move the website to production on a dedicated server with a hosting company.

Install OS

I wanted this to be easy and without much effort. I also did not want to partition my drive and do install etc, so I went ahead and downloaded a already configured Vmware Ubuntu 9.04 appliance from Vmware marketplace. I also downloaded a Vmware Player to run the appliance. I installed both software on my windows XP Platform and I had a running Ubuntu OS in my box in half an hour. The cool thing about the appliance I downloaded was that it already had the vmware tools in-built into it. This made sharing files between my Windows box and the Guest Ubuntu OS so easy.When you start Ubuntu OS in the player, you go to the menu tab and under VM tools select and assign a directory from your local hard drive for sharing, after that you can see that directory like any other mounted drive in Ubuntu OS.

Install IDE

I decided to use Netbeans as my PHP development platform as I had used netbeans for some of my JAVA projects. I downloaded the latest netbeans IDE from Java site and installed it. Please do not install netbeans from Ubuntu Package Manager as it does not install the latest version of Netbeans IDE. Also you have a choice to install only PHP or JAVA in netbeans IDE. I downloaded the complete package. Before installing netbeans do not forget to install the Java components. Open a terminal window in Ubuntu and do the following
# sudo apt-get install sun-java6-bin sun-java6-jdk
# sudo apt-get install sun-java6-plugin
Then type in the terminal
# which java
# which javac
If you get correct answers for these queries you are ready to install the netbeans IDE.

Install Database and Web Server

Installing LAMP stack in Ubuntu was very easy. Just follow the steps outlined in this Netbeans PHP Link. Now that the stack is installed you need a tool to administer the databse. I installed PHPMYADMIN to do the task.Ubuntu package manager has PHPMYADMIN already in it. So just open a termial window and type,
# apt-get install phpmyadmin
and that should take care of it. Once the Stack has been installed and configured properly you are ready to start working on your social networking website.

I had some hiccups on the way to my install.

I forgot my MySQL admin password and so wanted to reset the root access. I followed the following steps to reset the root pass word
Step # 1: Stop the MySQL server process.
# sudo /etc/init.d/mysql stop
Step # 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables option so that it will not prompt for password
# sudo mysqld_safe --skip-grant-tables &
Step # 3: Connect to mysql server as the root user
# sudo mysql -u root
Step # 4: Inside mysql cmd client, Setup new root password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
Step # 5: Exit and restart MySQL server
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
# mysql -u root -p
I found I had problems with my Vmtools drive share. I was not seeing my shared Windows Drive anymore on the Guest Ubuntu OS. 
The normal automatic updates that are done in the Ubuntu OS package manager had overwritten kernel files and due to this the vmtools host-guest file system driver which enables drive sharing is no more loaded. If you find this condition do the following,go to a terminal window and type
# sudo vmware-config-tools.pl -d
and if for any reason you find your Vmtools broken in your OS do the following,
# wget http://chrysaor.info/scripts/ubuntu904vmtools.sh
# sudo bash ./ubuntu904vmtools.sh

Error - 'Connection for controluser as defined in your configuration failed'
at the bottom of phpmyadmin login page.
After much search, I did the following to correct the problem.Go to a terminal window and type


# cd /usr/share/doc/phpmyadmin/examples/
# sudo guzip create_tables.sql.gz
# sudo gunzip create_tables.sql.gz
# mysql -u root -p < create_tables.sql
Now open the file config-db.php by typing
# gksudo gedit /etc/phpmyadmin/config-db.php
Check the values of contents of the following variables
$dbuser='phpmyadmin';
$dbpass='xxxxxxx';
Finally, Log in as root at http://localhost/phpmyadmin and create a user name phpmyadmin that can connect from localhost then add add at least SELECT, INSERT, UPDATE, DELETE privileges to the newly created phpmyadmindb for the user phpmyadmin using the password identified from /etc/phpmyadmin/config-db.php. After this logout and login and you will see the error mesaage no more.

This concludes my efforts to setup a Platform for installing and developing my Social Networking website. In my next post I will write about my research and its conclusion on choosing a open source social networking platform for my web business.

No comments:

Post a Comment