Installing PHP/Apache

See our page here, works with Raspberry Pi OS too

Adding Your HTML, PHP etc Files

Copy them into the “/var/www/html/” directory.

You will need root permission to write to this directory, so if you are using the GUI file manager use “sudo su” to elevate yourself to the root user before starting the GUI with “startx”

Restarting Apache


sudo service apache2 restart

Change The Password!

If your RPi will be connected to the internet or a public network a priority is to make the Raspberry Pi more secure by not using the default username and password. To change the password for the pi user after logging in:


passwd

Performance Tuning

If you are not using the HDMI out it is sensible to reduce the amount memory given to the RPi graphics to say 16MB using the config tool:

The configuration file

sudo nano /etc/apache2/sites-enabled/000-default.conf

sudo raspi-config

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through resources like this. We hope you find it helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support here. If you need help with a problem please use one of the many online forums.

Comments

  1. mitchellrj

    10 years ago

    This configuration is potentially dangerous. Allowing Apache to have passwordless sudo means that vulnerabilities in any web app you serve using it (WordPress, Drupal, Django, anything) could be exploited to gain COMPLETE control over your Raspberry Pi and anything connected directly to it. Also consider that the aforementioned software is very common and all have had numerous vulnerabilities in the last few years that could lead to this scenario.

    If you completely trust your Pi, network, all its users and all the devices connected to it then this might be OK, but in most circumstances you should NOT give Apache passwordless sudo.

  2. gazz

    4 years ago

    not able to sudo after completing this….

  3. twicejr

    4 years ago

    I agree with tom. They can mount all other drives in the network rw, if windows isn’t configured properly for example, when rpi is in the same subnet!
    Partially agree about rpi being hacked (by ITSELF) not being a big problem, lol.

  4. Tom

    4 years ago

    for a number of reasons adding www-data to the sudoers is a VERY bad idea.

  5. awesoman

    4 years ago

    great tutorial, but upon installing phpBB3, it says that the Directory is unwriteable. What can I do about this?

  6. Pingback: Web Interfaces « Raspberry Pi Projects

Comments

Your email address will not be published. Required fields are marked *