Home > How To, Raspberry pi, Technology > How to setup a webserver with PHP on Raspberry Pi

How to setup a webserver with PHP on Raspberry Pi

October 21, 2012 Leave a comment Go to comments

This will show you how to turn your raspberry pi in to a light weight web server running lighttpd instead of full fat apache and it will also be running PHP (P Hypertext Preprocessor) ready for any website you want to run on it.

1) Change the default password (Change Password Instructions)

2)Install the Lightptd by running the following command

sudo apt-get install lighttpd

(we use sudo command for “run as admin” as the standard account is not an admin)

To see if it was successful browse to your raspberry pi and should see the following webpage

3) Install the PHP by running the following command

sudo apt-get install php5-cgi

4) Now we need to link the PHP software to Lighttpd software we installed early by running the following command

sudo nano /etc/lighttpd/lighttpd.conf

Add the following highlighted red lines to the .conf file and save with ctrl+x

——————————————————
server.modules = (
“mod_access”,
“mod_alias”,
“mod_compress”,
“mod_redirect”,
“mod_fastcgi”,
#       “mod_rewrite”, )
——————————————————

and the following at the bottom of the file

——————————————————
   fastcgi.server = ( “.php” => ((
                     “bin-path” => “/usr/bin/php-cgi”,
                     “socket” => “/tmp/php.socket”
                 )))
——————————————————

5) Restart the Lighttpd software by running the following command

sudo service lighttpd restart

(You should see the following)

——————————————————
[ ok ] Stopping web server: lighttpd.
[ ok ] Starting web server: lighttpd.
——————————————————

6) Now we need to create a test file to see if the PHP is working on the raspberry pi by doing the following

sudo nano /var/www/index.php

and adding the following information into the file and save with ctrl+x

——————————————————
<?php
 phpinfo();
?>
——————————————————

7) To see if it was successful browse to your raspberry pi and should see the following webpage instead of the standard lighttpd page you looked at earlier.

 You now have a working light-weight web server with PHP on your Raspberry Pi

Advertisements
  1. October 26, 2012 at 8:07 am

    Reblogged this on Gigable – Tech Blog.

  2. Praetorian
    July 3, 2013 at 8:55 pm

    Instead of modifying /etc/lighttpd/lighttpd.conf executing lighty-enable-mod fastcgi-php shoudl also work

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

raspberrypicloud

The University of Glasgow's Raspberry Pi Project

Tech-o-rama

Your all round solution for tech problems (and some others things...like spelling errors)

thedomesticfringe.com/

telling stories - making memories

Raspberry Pi Kid

A 14-year old's adventures with Raspberry Pi

Naked Security

Computer Security News, Advice and Research

Grumpy IT Girl

I'm not a very good writer

Dustin Software

Because programming is fun!

Pinoy Tekkie

USER-FRIENDLY TECHNOLOGIES FOR THE PINOY NOOBIES

petRockBlog

Fun stuff for technics enthusiasts

I Kissed My Date Goodnight

A single thirty-something embarking on motherhood through the miracle of adoption.

projectz

Tech, Gadgets, Photography, Social Media and Poor Spelling

Programming My Rasberry Pi

A brave fool's adventures into the unknown!

Chris Ainger's Blog

Where Fishing Meets Computing

PIPAL

Information wants to be free

ITtechExec: Protecting Tech Careers Since 2001

Technical Career Advancement: Transformed. Guaranteed.

CRUNCHEDD

Entertainment, Technology, Social Media Updates from in Between the Web…

StartupTunes

An Exclusive Web 2.0 Startups Review Blog

The Life of Me

Just another IT blog

NJrajgelani

The Best Place for Deziners

%d bloggers like this: