How to Make a Website on Raspberry Pi Zero WH using Apache & PHP 8.2 (Specially for Armv6)
Raspberry Pi Zero WH is a versatile single-board computer that can be used for various projects, including hosting your own website. In this tutorial, we’ll guide you through the process of setting up a web server using Apache and PHP 8.2 on a Raspberry Pi Zero WH, with a special focus on Armv6 architecture. We’ll be using the Raspbian Linux OS version 6.1.0-rpi7-rpi-v6, released on November 24, 2023.
Prerequisites
Before we begin, make sure your Raspberry Pi is up-to-date. Open a terminal and run:
sudo apt update
sudo apt upgrade
Installing Apache and PHP
To set up the web server, install Apache and PHP with the following commands:
sudo apt install apache2
sudo apt install libapache2-mod-php
sudo /etc/init.d/apache2 restart
Configuring Permissions
Navigate to the web server directory and adjust permissions:
cd /var/www
sudo chown alpha:html
sudo chown www-data:html
cd html
Creating Your First Web Page
Now, let’s create a simple PHP file for your website. Use your preferred text editor to create a new file:
sudo nano index.php
Add some basic PHP code to test your server. For example:
<?php echo "Hello, Raspberry Pi!"; ?>
Save the file and adjust permissions:
sudo chown www-data: index.php
Configuring PHP
Edit the PHP configuration file:
sudo nano /etc/php/8.2/cli/php.ini
Make sure the following settings are configured appropriately:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
Save the changes and restart Apache:
sudo /etc/init.d/apache2 restart
Conclusion
Congratulations! You’ve successfully set up a basic web server on your Raspberry Pi Zero WH using Apache and PHP 8.2, optimized for Armv6 architecture. This is a great starting point for hosting your own website and experimenting with web development on a compact and affordable platform.
Feel free to explore further customization and features to enhance your Raspberry Pi web server experience. Happy coding!