Install PHP5 and Apache on Ubuntu | Guide

Setting Up PHP on Ubuntu with Apache
For developers working with PHP, Apache is a commonly used web server. This guide provides a straightforward method for configuring PHP on an Ubuntu system.
Adding Repositories and Installing Packages
The initial step involves adding necessary repositories to Ubuntu’s sources list. This is achieved through the command line interface.
Execute the following commands in a terminal window:
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
If the Apache web server is already present on your system, the first command can be skipped.
Locating Your Web Files
Following the installation process, your website files should be placed within the /var/www/ directory.
This directory serves as the root for your web applications accessible through Apache.
Apache and PHP are now configured to work together, allowing you to deploy and run PHP-based web projects on your Ubuntu server.