This is part of a series on hosting a website on the Raspberry Pi. Click the Raspberry Pi Webserver in the Blog Series to the right for the complete steps.

With Apache working, let’s move on to a scripting language for our website, PHP. Here is the install command:

sudo apt install php -y

To test PHP, use this command to create the file index.php.

sudo nano /var/www/html/index.php

Paste this code in the newly created file, then save and close the file.

<?php
     phpinfo();
?>

Opening this file in the browser will give us some PHP information. Enter 192.168.2.26/index.php (replace with your Raspberry Pi’s IP address) into the browser and you should see this page displayed:

With PHP complete, let’s move to the next post : Installation of MariaDB

Share this content: