Tags:

Install a LAMP (Apache, PHP, Mysql) On Ubuntu

Tuesday, April 19, 2011 EDT

by: Eric Potvin

Tags: php apache ubuntu linux mysql

This guide will help you to install a local web server using Apache, MySQL and PHP on Ubuntu.

Install apache2:

sudo aptitude install apache2
Edit the /etc/apache2/httpd.conf to setup your ServerName
ServerName <myhostname>
Start apache2 and test:
sudo /etc/init.d/apache2 start

* If everything is OK you should see an ordinary HTML page when you type: http://localhost in your Firefox browser

Stop apache to install other component:
sudo /etc/init.d/apache2 stop

Let's install PHP

sudo aptitude install php5 libapache2-mod-php5
Restart Apache
sudo /etc/init.d/apache2 start
To test the PHP installation, create a dummy file in /var/www/
<?php
    //file: test.php
    phpinfo();
?>

PDO (PHP Data Objects)

If PDO (PHP Data Objects) is not installed, this is how to install it: First, install some needed modules:
sudo aptitude install php5-dev libmysqlclient15-dev
* libmysqlclient15-dev is needed by PDO mysql driver Next, install the PHP pear:
sudo aptitude install php-pear
Then, you can install the PDO itself an the database specific driver, for example mysql driver:
pecl install pdo
pecl install pdo_mysql
Check the php.ini open the /etc/php5/apache2/php.ini and add check if these following lines are there
extension=pdo.so
extension=pdo_mysql.so
if not installed, you can simply add it And don't forget to restart your web server.
sudo /etc/init.d/apache2 restart

Install MySQL

MySQL:
sudo aptitude install mysql-server
Set your root password
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypass');
Try running it
mysql -uroot -p
* you password will be asked! Now let's install mysql with apache
sudo aptitude install libapache2-mod-auth-mysql php5-mysql
Restart apache and test
sudo /etc/init.d/apache2 restart
* (optional) you can setup your /etc/mysql/my.cnf file regarding your needs

Installation done! enjoy!

Be the first to reply!

No comments!
Share this article:

Add a comment

* If your comment require a response from us, please make sure you leave your email

Captcha

* is required
The posting of advertisements, profanity, or personal attacks is prohibited.
Please review our terms of use

Latest Articles

Top Articles

Category List

Top of the page
Loading, please wait ...