Installing Apache 2.4

sudo apt-get install apache2
To create a new virtual host, firstly, you need to create appropriate directories:
sudo mkdir -p /var/www/test.loc/www
sudo mkdir -p /var/www/test.loc/logs
Usage of -p allows the creation of nested directories specified in the path.
Apache comes with a default virtual host called 000-default.conf which it uses by default, but we are going to create a new one - test.loc.conf for our domain test.loc:
sudo nano /etc/apache2/sites-available/test.loc.conf
<VirtualHost *:80>
    ServerName test.loc
    ServerAlias www.test.loc

    DocumentRoot /var/www/test.loc/
    <Directory /var/www/test.loc/>
        AllowOverride All
    </Directory>

    CustomLog  /var/www/test.loc/logs/access.log common
    ErrorLog /var/www/test.loc/logs/error.log
    LogLevel warn
</VirtualHost>
 
Save and Save As are both accomplished with the Write Out command, Ctrl+O. When prompted, press enter to accept the existing file name.
In order to allow the usage of the domain, execute the following command which creates a symbolic link between sites-available and sites-enabled to activate the host we’ve created:
sudo a2ensite test.loc
Make changes in hosts file. To open it as usual use nano:
sudo nano /etc/hosts
Add the following line:
127.0.1.1 test.loc

Installing MySQL

You need install MySQL as follows:
sudo apt-get install mysql-server mysql-client
During the installation, MySQL will ask you to set a root password. It's very important to keep it, but if you missed this step, it's very easy to set the password later, using MySQL shell.

Installing PHP

Using the repository of Ondřej Surý, we can install both stable versions of Apache 2.4 and PHP 5.5.x just following this simple steps. Add the launchpad repository to your system:
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install php5
Add a simple PHP script to test out virtual host:
sudo nano /var/www/test.loc/index.php
With the following code:
<?php
   phpinfo();
Finally, restart Apache:
sudo service apache2 restart
Now you can check test.loc in your browser. This file will display lots of useful details about your PHP installation.
To get MySQL support in PHP, you can install the php5-mysql package. Also install some other PHP5 modules which possible need for your applications:
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

Installing phpMyAdmin

Before installation unit you need to make sure that you have MySQL server and php with required modules installed.
Installing phpMyAdmin as follows:
sudo apt-get install phpmyadmin
During the installation, you will be prompted to choose the type of web server, just choose apache2.
After the installation has been completed, you need to include phpmyadmin to the apache configuration:
sudo nano /etc/apache2/apache2.conf
Add the next line to end of the file:
Include /etc/phpmyadmin/apache.conf
To go down to the end of the file, press Ctrl+V.
Restart Apache:
sudo service apache2 restart
You can reach phpmyadmin by opening test.loc/phpmyadmin in your browser.

ที่มาset-up-apache-2-4-php-5-5-mysql-on-ubuntu-14-10