By following this you will be able to install apache2.4 server on ubuntu machines and configure it to work with PHP.
Install apache2.4 server on UbuntuStep-1 Install Apache2.4
To install Apache2.4 run the follwoing commands on terminal.
$ sudo apt update $ sudo apt install apache2
First line will update the repositeries and second line will install "Apache2.X" latest stable version available. After installation is finished a success meassage will be displayed.
Now verfiy its installation by opening a browser and enter url "http://localhost". If installation is successful the following like page appears on your browser.
Default location of hosted website is /var/www/html. To make your website running place your files here. This location can be edited by editing its virtual host file present at /etc/apache2/sites-enabled/000-default.conf
Read Also: Install PHP on Windows, Ubuntu MachinesStep-2 Configure Apache2.4 to work with PHP
To make your installed "Apache2.4" server parse .php files you have to install libapache2-mod-php PHP module using the following command.
$ sudo apt-get install libapache2-mod-php
After successful installation restart Apache2 service using following command.
$ sudo service apache2 restartStep-3 Test PHP working with Apache2.4
To test its working let's create a test file info.php and save at the server document root path /var/www/html/. Add the following line to this file and save it.
<?php phpinfo(); ?>
Now open your browser and enter the url "http://localhost/info.php". You should be able to see the PHP configuration installed on your system.
If you could able to get it, congratulations! you have successfully installed and configured PHP and Apache2.4.