Monday, February 28, 2011

How to Install Apache, PHP, MySQL, and PHPMyAdmin on Ubuntu

Install Apache:
sudo apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils

Install PHP:
sudo apt-get install php5 libapache2-mod-php5 php5-common php5-gd php5-mysql php5-imap php5-cli php5-cgi php-pear php-auth

Install MySQL:
sudo apt-get install mysql-server mysql-client
here you will be ask to input root password for the mysql

Install PhpMyAdmin:
sudo apt-get install phpmyadmin
here you will be asked some question to configure the phpmyadmin, just go through the wizard after it finish installed.

To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf.

Include /etc/phpmyadmin/apache.conf
(It might be no need to add this line any more -

Now your server is ready. Before you test please make sure to restart the server:

/etc/init.d/mysql restart
/etc/init.d/apache2 restart

then point your browser to

Enable mod_rewrite
sudo a2enmod rewrite

Install cURL
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Enable modules

sudo a2enmod cache & a2enmod disk_cache & a2enmod proxy & a2enmod proxy_http & a2enmod headers & a2enmod expires

Other tools

sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

[SOLVED] “Could not reliably determine the server’s fully qualified domain name, using … for ServerName”

You might probably faced the same following error while you were restarting the Apache server on Ubuntu.

in either httpd.conf or apache2.conf in /etc/apache2 and restart apache the notice will disappear. 

sudo gedit /etc/apache2/httpd.conf
sudo gedit /etc/apache2/apache2.conf

By default httpd.conf file will be blank. Now, simply add the following line to the file.

ServerName localhost

Save the file and exit from gEdit.

Finally restart the server.
sudo /etc/init.d/apache2 restart


More Help:



  1. u can chk whether the mod_rewrite is enabled using "apache2ctl -M" command.

  2. This is a nice guide for Apache, PHP, MySQL, PHPMyAdmin separate installation. Very helpful.

    Thanks Maduka.