How to Install Apache Web Server on Raspberry Pi
Updated on
•6 min read

Apache HTTP server is one of the most popular web servers in the world. It is an open-source and cross-platform HTTP server that powers a large percentage of the Internet’s websites. Apache provides many powerful features that can be extended through additional modules.
In this tutorial, we will explain how to install Apache Web server on Raspberry Pi. We’re assuming that you have Raspbian installed on your Raspberry Pi .
Installing Apache
Apache is available in the default Raspbian repositories and the installation is pretty straightforward.
First, update the package index and afterward install the apache2
package by running the following commands:
sudo apt update
sudo apt install apache2
That’s it,at this point you have Apache web server installed on your Raspberry Pi.
To verify that everything works as expected, open your browser, type your Raspberry Pi IP address http://PI_IP
and you will see the default Apache welcome page as shown on the image below:

The page includes some basic information about Apache configuration files, helper scripts, and directory locations.
This default Apache web page is named index.html
and it is stored in the /var/www/html
directory. If you want to modify this page you need to edit the file as a sudo
user. You can also remove the file and add your own HTML files.
Apache log files access.log
and error.log
are located in the /var/log/apache
directory. If you experience any issue the log files should tell you what went wrong.
Installing PHP
If you want to serve dynamic PHP files on your Raspberry Pi you’ll need to install PHP and PHP Apache module:
sudo apt install php libapache2-mod-php
Once the packages are installed to enable the PHP module, restart the Apache service:
sudo systemctl restart apache2
To test whether your Apache web server is configured properly for PHP processing, create a new file called info.php
inside the /var/www/html
directory with the following code:
<?php
phpinfo();
Save the file, open your browser of choice and visit http://PI_IP/info.php
. This page will show information about your PHP configuration.
Conclusion
You have successfully installed Apache and PHP on your Raspberry Pi board. You can now start using Apache as a web or proxy server.
If you have any questions or feedback, feel free to leave a comment.