How to Install PHP5 on Raspberry Pi

This site contains affiliate links to products. We may receive a commission for purchases made through these links.

A person can install the PHP5 system so they can use it with their Raspberry Pi system when they are working on the computer. There is software that is in development that will help a person download this and they will be able to manage their files and any web interfaces that go along with it.

Raspberry Pi

A person needs to become familiar with the Raspberry Pi system and board so they can learn how this program works and how they will be able to transfer files. A person should have the Raspbian or the Raspbian Lite operation installed on their system. It will make things easier to transfer. This will help a person become familiar with the system.

How to Install PHP5 on Raspberry Pi

To begin the file transfer, some things are going to be required. A person will need to have the Raspberry Pi board and they should become familiar with the starter kit.

A person should also have a micro SD slot located on their computer. It may be helpful to have one that is around 16 GB. They should also have a power supply for the Raspberry Pi so that the program will keep on running.

Needed Programs

Before a person installs the PHP5 program on their computer they are going to make sure they have specific programs on the computer. One of the programs that a person needs and they will have to install is the Apache 2 program. To get the PHP5 working a person will need to make sure Apache 2 is working.

Apache 2

Apache 2 is a program that is used in web server software. It will allow a person to have access to a webpage. This access is needed to run the PHP5 program. A person will also need this to open certain programs that end with things such as .html, .php, and other endings.

A computer has to be running a web browser and they will need to run the Raspberry Pi at the same time. Before a person can run the PHP5 they will need to install Apache 2 on the Raspberry Pi.

Installing the Apache 2

A person will need to enter some commands so that they can have this system installed on their computer. A person will need to enter pi@raspberrypi_ $ Sudo apt install apache2 –y. A box with several things will appear and a person will need to look it over. At this time the Apache is now installed on the computer.

A person will need to test the installation to make sure they have installed this in the correct manner. The test is simple to do. A person will need to enter /var/www/HTML. There will then be a list of files that will appear. A person will then see index.html that will appear in a folder.

A person will need to open the page. The page will then open up in the browser. A person will then enter their Raspberry Pi address including their host name.

A person will then need to type in their Raspberry Pi IP address in their browser and their local network. This will allow them to check and make sure this program is working. This will then allow them to continue with the installation process of the PHP5 and they can continue with this process.

Installation of PHP 5

When a person is ready to install the PHP 5 they are going to need to make sure some things are ready. PHP 5 is a server that is going to a scripted language. This is a hypertext preprocessor and this is used to help a person develop great web applications. There will be some tags on any applications and it is going to end with a specific extension. This extension will end with a .php.

Installing This Program

There is an easy guide to follow when it comes to installing the PHP 5 on the program. A person will need to install the PHP 5 and once they enter the code they will need to allow it to run.

They will need to enter pi@rapsberrypi:/var/www/HTML $ Sudo apt install PHP –y. When entering this code they may be able to remove the index.html. This will help create the script for the PHP that will be used to test the installation process.

If there is an index.php file a person will need to enter a code when they see the message. The code they will enter is the hello world.

When there is entered a new screen will appear. A person will then need to save their file. A person can save their file by entering a command. They will need to hit the CTRL +X and then the y button.

This will then be followed by the enter button that will allow them to exit and go to the next screen. After this, a person will need to restart the Apache 2 command. They can do this by entering pi@raspberrypi:// var/ www/ HTML $ sudo service apache2 restart.


To determine if things were installed properly a person will need to do the following test. They will need to test the Apache 2 by using the .php file. This will open the Raspberry and the Pi IP address. The hello world message should then appear. A person should also see the index.php script that they have entered in a previous step.

If everything is working as it should be, a person should then be able to remove the index.php from the file. They will be able to take it off from the /var/ www/HTML and the program should work as usual. They should have then successfully installed the PHP5 as part of their computer program and can use these features.

These are some ways that a person can make sure their raspberry pi can work with the PHP5. This will allow a person to have additional access to files and will allow a person to do more with their computer programs.

This guide will help a person make sure everything is set up correctly. All they need to do is follow the steps to make sure the PHP5 runs smoothly on Raspberry Pi. With a proper guidance and steps, a person will then be able to have it running in no time.

About The Author