A step by step guide on installing Apache with PHP
A simple way to run Apache and PHP on Windows is by installing a bundled package such as
XAMPP. Download XAMPP from the official website and run the installer. During setup,
ensure Apache and PHP are selected. After installation, open the XAMPP Control Panel and
start the Apache service. Open a browser and go to http://localhost to confirm
the Apache server is running. To test PHP, create a file named info.php inside
the htdocs directory with the following code:
<?php phpinfo(); ?>
Navigate to http://localhost/info.php. If the PHP configuration page appears,
Apache and PHP are correctly installed and working together.
On Ubuntu, install Apache directly from the package manager. First update the package list:
sudo apt update
Then install Apache:
sudo apt install apache2
After installation, start the service with
sudo systemctl start apache2. Open a browser and visit
http://localhost to see the Apache default page. Next install PHP and the Apache
PHP module:
sudo apt install php libapache2-mod-php
Restart Apache using sudo systemctl restart apache2. Create a PHP test file
inside the web root directory:
sudo nano /var/www/html/info.php
Add the phpinfo script and save the file. When you open
http://localhost/info.php in your browser and see the PHP configuration page,
the Apache–PHP environment is working correctly.