Installing LAMP on Ubuntu 9.10
Information Technology November 30th, 2009Installing and configuring LAMP (Linux, Apache, MySQL, and PHP) is easy in Ubuntu Linux. If you have internet connection in your system, you can able to download the necessary applications using apt-get or synaptic package manager tools.
In this tutorial, I have given step-by-step procedure to setup LAMP web server environment in Ubuntu 9.10 operating system.
Installing Apache:
The first application we will install is the web server Apache. To get started open your console and type:
sudo apt-get install apache2
Now enter the system password to download and install automatically. To test it, point your web browser to http://localhost/. If installation is successful, a text “It Works!” will display.
The location for saving webpages and script files are as follows.
Web Pages: /var/www
Script Files: /usr/lib/cgi-bin
Apache Configuration: /etc/apache2/sites-available
You can access the webpages using default address 127.0.0.1, system name, or localhost. If you wish to setup your own domain name, follow the steps bellow. (In this tutorial, i have chosen www.ashok.com as my domain name.)
sudo gedit /etc/hosts
Add “127.0.0.1 www.ashok.com” in the hosts file and save it. Now the problem is almost solved. To avoid errors in configurations, do the bellow steps too.
The first step is to make a copy of the original configuration file.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ashok.com
The second step is to change the configuration file to your own domain name.
sudo gedit /etc/apache2/sites-available/ashok.com
Add few lines in the configuration file (shown in blue color) as given bellow.
<VirtualHost *:80>
ServerAdmin webmaster@ashok.com
DocumentRoot /var/www
ServerName ashok.com
ServerAlias www.ashok.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
:
:
.
The third step is to active new domain ashok.com and deactivate old domain.
sudo a2ensite ashok.com && a2dissite default
Finally restart the Apache web server.
/etc/init.d/apache2 reload
Your own domain name has been configured successfully.
Installing PHP:
The second application we will install is the PHP. To get started open your console and type:
sudo apt-get install php5 libapache2-mod-php5
Once this finishes we need to restart Apache. This will apply the changes.
sudo /etc/init.d/apache2 restart
Now let’s test it by replacing ‘/var/www/index.html‘ with index.php using command:
sudo cp /var/www/index.html /var/www/index.php
Replace the line with <?php phpinfo(); ?> in index.php file through an editor, using command ‘sudo /var/www/index.php‘. If PHP is installed properly, the page will display the information about installed modules of PHP.
Installing MySQL with PHP5:
Install all the MySQL stuff:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
When you get a prompt enter a password you would like to use as the root MySQL user. Once done open, ‘sudo gedit /etc/mysql/my.cnf‘ and change the bind-address to your local IP. (Usually 192.x.x.x number). Note that this can be a security problem, because your database can be accessed by others computers than your own. Skip this step if the applications which require MySQL are running on the same machine.
Change the line bind-address = localhost to your own internal ip address ( e.g. 192.168.1.1 as bind-address = 192.168.1.1). If no need, skip this statement.
If your ip address is dynamic you can also comment out the bind-address line and it will default to your current ip.
Extra Stuff:
Installing phpMyAdmin:
All MySQL tasks including setting the root password and creating databases can be done via a graphical interface using phpMyAdmin or MySQL-Admin.
sudo apt-get install phpmyadmin
After phpMyAdmin is installed you can see it view it, http://localhost/phpmyadmin/.
User Name: phpmyadmin
Password: your_password
Now, you have to grant permission to create or modify database. To do this you must be a super user (su). By default Ubuntu offers only sudo mode. To be safe, create new root password:
sudo passwd root
Keep the su password safely. It is needed to control every operations in Ubuntu. Remember that sudo and su password are different. !!!
Open your console and type:
su
/etc/init.d/mysql start
mysql -u root -p
mysql>GRANT ALL PRIVILEGES ON *.* TO ‘phpmyadmin@localhost’ IDENTIFIED BY ‘your_password’ WITH GRANT OPTION;
You can now able to create or modify tables through graphical interface of phpMyAdmin.
mod_rewrite:
Chances are you want to use mod_rewrite in your applications to make URLs a bit more pretty. It is also required by lots of webserver applications, like WordPress, Drupal, etc.
Do the following:
sudo a2enmod rewrite
/etc/init.d/apache2 restart
Method to Start / Stop Apache:
Use the following command to run Apache:
sudo /usr/sbin/apache2ctl start
To stop it, use:
sudo /usr/sbin/apache2ctl stop
To test configuration changes, use:
sudo /usr/sbin/apache2ctl configtest
Finally, to restart it, run:
sudo /usr/sbin/apache2ctl restart
December 20th, 2009 at 1:43 AM
Well-written. Thanks. I have been learning a lot about different CMS programs lately. I have also been experimenting with setting up an e-commerce site using WordPress. Have you ever done that? Any suggestions for me? It’s pretty fun learning it. Visit my blog if you’d like to read more. Thanks again for this blog – it is really informative.
February 12th, 2010 at 7:02 AM
I am having trouble seeing your website. It displays all weird with text displaying incorrectly. You might want to check it out.
February 18th, 2010 at 5:38 AM
im very grateful for your informations
February 26th, 2010 at 8:35 AM
Hi, i just thought i
March 7th, 2010 at 6:00 PM
Brilliant post! This would aid most of us learn about this matter. Do you want to incorporate video clips together with these? It would without any doubt help out. Your reason was spot on and owing to you; I perhaps won’t have to describe everything to my pals. I could just lead them here.
March 9th, 2010 at 2:54 PM
I am really enjoying reading your well written articles. It looks like you spend allot of effort and time on you blog.I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
March 12th, 2010 at 4:02 PM
Thanks for sharing this group of lesson learned, you have added a few points that I need to go away and consider.
March 19th, 2010 at 5:48 AM
I wanted to thank you for this excellent read!! I definitely enjoyed every little bit of it. I have you bookmarked your site to check out the new stuff you post.
March 20th, 2010 at 5:49 PM
Your comment sounds so much like something I’d say that I’m smiling bigger than usual. Welcome to the conversation.
March 28th, 2010 at 8:57 AM
Good Day, How are you? I must say that i enjoy the special source of content of your website a great deal, can’t help asking my self where you find all of this from. Best regards Ps3Ylodfix
March 31st, 2010 at 3:21 AM
Great post, Helped me out, Very good!
. I am a computer technician, if you want to you can take a look at my recent article on cleaning up Slow computers. Best regards Richard Nordstrom
April 5th, 2010 at 7:33 PM
Hi There! I ran into your site absolutely by mistake, and it turned out to being a blessing. You bring a lot of interesting things to the table and I will be back for more
Thanks!
April 6th, 2010 at 2:00 AM
Hi, I applaud your blog for informing people, very interesting article, keep up it coming
April 9th, 2010 at 8:47 AM
Keep up the great writing.
April 9th, 2010 at 7:01 PM
awesome post dude
April 13th, 2010 at 4:24 AM
Thanks great website
April 14th, 2010 at 10:41 PM
Couldn’t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!
April 15th, 2010 at 12:56 PM
Hi,Cheers to the site owner for giving me some solid ideas. Will bookmark this blog for referance.
April 22nd, 2010 at 1:58 AM
Wow, very straight forward and worked right off the top. Thank you for taking the time to post this! Took me about 20 minutes to set up Ubuntu in vitual box, another 2 to set the port forwarding on router and on the virtual box host, then about 5 more minutes to work these steps and have a page report the PHP config info from a remote computer. That was all before breakfast. I had set my domain name up a while ago and had it point to my static IP, so add a little more time for that. All in all, a very well done LAMP setup posting. Thanks again!
April 23rd, 2010 at 3:23 AM
Good Day, How are you? I have to say that i enjoy the special information of your blog alot, can’t help wondering where you get all of it from. Best regards Julius Mcnett
April 25th, 2010 at 5:57 AM
It is great to have the chance to read a good quality article with useful details on topics that a lot are interested on. The fact that the data indicated are all first hand on real experiences even aid more. Keep doing what you do as we love reading your work.
May 5th, 2010 at 4:55 AM
Good blog, many amusing points. I think three of days ago, I have discovered a similar article.
May 6th, 2010 at 3:16 PM
Your RSS feed not work in my browser (google chrome) how can I fix it?
May 7th, 2010 at 4:40 AM
Nice post, thanks for writing!
May 11th, 2010 at 3:03 AM
Nice blog!
May 11th, 2010 at 8:14 AM
Not daily do you encounter good writing with interesting information like yours. You are really appropriate on the topics you create which is very functional to many. Carry on the excellent work so we have something to expect.
May 11th, 2010 at 11:43 PM
I just book marked your blog on Digg and StumbleUpon.I enjoy reading your commentaries.
May 17th, 2010 at 2:03 AM
I wanted to thank you for this great read!! I definitely enjoying every little bit of it.I have you bookmarked to check out new stuff you post.
May 17th, 2010 at 3:28 PM
Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.
May 17th, 2010 at 9:05 PM
Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.
May 17th, 2010 at 9:05 PM
Advantageously, the post is actually the sweetest topic on this registry related issue. I fit in with your conclusions and will thirstily look forward to your future updates. Just saying thanks will not just be enough, for the extraordinary clarity in your writing. I will immediately grab your rss feed to stay informed of any updates.