Install a LAMP (Apache, PHP, Mysql) On Ubuntu
Tuesday, April 19, 2011 EDT
by: Eric Potvin
This guide will help you to install a local web server using Apache, MySQL and PHP on Ubuntu.
Install apache2:
sudo aptitude install apache2Edit 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-php5Restart Apache
sudo /etc/init.d/apache2 startTo 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-pearThen, you can install the PDO itself an the database specific driver, for example mysql driver:
pecl install pdo pecl install pdo_mysqlCheck 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.soif 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-serverSet 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-mysqlRestart 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!
Share this article: