Instructables
Hi there,
This is my first Instructable so all criticisms and comments are welcome.
This will show you how to set up a simple wired web server on your Raspberry Pi, with PHP and MySql.

The Raspberry Pi is a good choice for a webserver that will not recieve too much traffic, such as a testing server, or small intranet, as it doesn;t get too hot (so is nice and quiet), and only uses around 5 Watts of power (costing £3.50 a year where I am if it's running 24/7)

In the future I might add how to set up a wireless server.

If you have any problems, post them in the comments, or PM me - I'm happy to help.
 
Remove these adsRemove these ads by Signing Up

Step 1: You will Need

To create a simple web server, you will need:

1. A power supply (Micro USB)
2. A network cable
3. A HDMI cable (or Component cable) as well as a screen and USB keyboard
3. A Raspberry Pi
4. An SD card (2GB or more)
5. An SD card reader for your computer
6. Win32DiskImager (For Windows) or dd (for Unix)
7. The Raspberry Pi Debian Image
8. PuTTY (For Windows) or any other SSH client
9. Around an hour of free time

You can download the software from the following locations:

http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml (for Win32DiskImager)
http://downloads.raspberrypi.org/download.php?file=/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip (Debian Image)
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html (for PuTTY)

Step 2: Format SD Card

Firstly, you need to install the Debian image onto an SD card (2GB or more).
(The image can be downloaded from http://downloads.raspberrypi.org/download.php?file=/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip)

You can do this using the Win23DiskImager tool for Windows (downloaded from http://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml)

Insert your SD card.
Once you have downloaded the above, Extract the Debian image, and the Imaging tool, then run Win32DiskImager.
Ignore the error that you will see.
Select the Image file (debian6-19-04-2012) and your SD card, then click "Write", it will ask you to confirm, click "Yes". Then enjoy a break, as it usually takes a couple of minutes to write.

Once the write process has finished, you can remove the SD card, then the fun begins.
1-40 of 191Next »
dale3h1 year ago
Just wanted to share my experience with this Instructable. Everything went smoothly until it was time to connect to MySQL from a remote machine on the same network. So here's how to fix that:

1. Grant access to your remote machine using: GRANT ALL ON *.* TO 'root'@'192.168.1.%' IDENTIFIED BY 'your_password_here'; (I used 192.168.1.% so that any computer on my network can connect to it)
2. Go into the my.cnf file (sudo nano /etc/mysql/my.cnf) file and look for "bind-address" and comment this out (put a # in front of the line)
3. Reload MySQL config (service mysql reload)
4. Restart MySQL server (service mysql restart)

Hope this helps, and thank you for the great Instructable :)

is the "GRANT ALL ON *.* TO 'root'@'192.168.1.%' IDENTIFIED BY 'your_password_here';"
a command you type into the terminal? or does it go into some config file?
btw, I can advise anybody using a remote linux server (like the Raspberry) to install 'webmin' as well

drcurzon (author)  dale3h1 year ago
Hi there,
Thanks for posting this to help others :)
Daniel
aidenv3 days ago

To log in again using the user pi you need to add that user to the group pi.

ssh to pi with user root

type sudo useradd -g pi pi

type passwd pi

type new UNIX password/confirm

type exit

type exit

itsleif9 months ago
I followed the steps, all works fine, but now I cannot log in any more. After restart the pi user login does not work and the new password does not work either. I also tried the root user with both passwords the old and the new, nothing works.

No I cannot log in my pi any more :( I cannot change the password file either because my mac does not mount the linux partition...

how can login again?
MattC1 itsleif5 days ago

remove the # infront of pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash

angelo49 itsleif2 months ago

Hey! Same thing happened to me. What did you end up doing??? I'm so stressed! Thank you!

evan10142 months ago

Thanks for this, now i can't log-in anymore -_- . Somebody Help,

Remove the # infront of pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash

techieeb146 months ago

I am having trouble following your directions on making the RaspberryPi web server.

I can't run "mv boot_enable_ssh.rc boot.rc" because there is no such directory.

What did you do inbetween Then type "hostname xxxxxx" where "xxxxxx" is what you want to call your server (I chose "raspberryPi" to make it easy).

Please Note that you cannot have any spaces in the hostname.

Finally for this step, type in "ifdown eth0" and hit Return / Enter.
Once that has finished, type "ifup eth0" and hit Return / Enter.

Some personal help would be greatly appreciated.

SSH is already enabled on newer distributions of Debian, so the "mv boot_enable_ssh.rc boot.rc" step is not needed. Everything else is though.

In the newest distribution of Debian Wheezy, it seems that ssh is already enabled by default. (I tried this step a dozen times, not sure what I was messing up until I Googled it...)

erikm27 days ago

The link to the download for the software does not exist anymore. Can you provide another. Greatly appreciated!

-Erik

sk_910 days ago

Thank you!
One Question: Once the SQL server has been installed and started, it can be accessed via JDBC from another device in the network? My plans are the following: An Android App which uses the data (and creates new data sets) in the MySQL database on the Pi.

hamcircuit1 year ago
I tried adding that and I still just get a blank page still.
drcurzon (author)  hamcircuit1 year ago
try:
sudo apt-get install phpmyadmin

WAIT FOR IT TO INSTALL

nano /etc/apache2/apache2.conf

AT THE END OF THAT FILE TYPE

#Include phpmyadmin
Include /etc/phpmyadmin/apache.conf

SAVE THE FILE THEN

service apache2 restart

then navigate to:
http://HOSTNAME HERE/phpmyadmin

Let me know how it goes, Dan.

For me works!

Pra mim funcionou! Obrigado Daniel!

I tried this and it doesn't work.

I had a similar problem, for me the fix was to go into my FTP client and right click the admin folder and change permissions to 777 for all files and subfolders

adamant628 sdobbie10 months ago
don't forget to use sudo before "nano" and "service"
jelimoore18 days ago
Hello,
I do not know if itis normal, but my web page response time is 9.7 seconds, what is wrong there?
photoace122 months ago
How do you add more users?

http://www.cyberciti.biz/faq/howto-add-new-linux-user-account/
or install webmin and use their GUI gui to do almost everything

Hi,

Would this be able to run an application server? Do you think that it could handle an OpenSim virtual world? Maybe with just 1 to 6 avatars logged in? And if yes, could you make an instruct-able about it? This one is great. you seem super knowledgeable.

Arman559220 days ago
2GB SD card ??? Is it an ssd hard drive or I'm out of date ? Or maybe it's MB ?

2 GB SD card, is a type of flash card, typically used for cameras, for examples:

http://www.newegg.com/Product/ProductList.aspx?Submit=ENE&DEPA=0&Order=BESTMATCH&Description=sd+card&N=-1&isNodeId=1

Arman559220 days ago
Sorry . I didn't understand something :(
jscanlan21 days ago

Great tutorial -- looking forward to others

Good job, was trying this for some time.

saved a lot of work.

zaxza1 month ago

You Need to delete the # that was put in front of pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash, it basically deletes the user "pi". Once thats is returned to how it started you can log into "pi". Anyone know how to set the Hostname for FTP or have I missed something?

dd'souza zaxza1 month ago

I'm no expert, but i think you would set the hostname running the 'raspi-config' command as root.

As for accessing the pi, I used my pi's FTP address in Notepad++, and it worked.

evan10142 months ago

Is Anyone Home? We need your answers to our questions!

boudreaupaul2 months ago

quick question... Since Mysql is now essentially owned by Oracle, is there an alternative method for using MariaDB?

once2go made it!2 months ago

Hello
Today stack on problem with "acess denide" under "pi" user/
Solving so simple:
You must get you SD card with file system plug it into Linux/Mac, and under -su delete "#" on passwd

Снимок экрана от 2014-06-23 23:23:20.png
evan1014 once2go2 months ago

Hey, i can't log-in in Raspberry pi using PuTTY SSH Client. Can you help me? Really appreciate for your help.

pherrmann33 months ago

Hey, this is a quite old tutorial but i hope you still follow its replies..

Very nice and easy guide.. I have this problem though..

PHP is installed but .php files do not open.. I googled everything but no real solution has come out of it.. arg.. Any help?

Oh, and, I almost forgot to ask.. How are you trying to run these files? Are you going to your pi's ip address like this in a web browser?

http://{raspipaddress}/{filename}.php

If you are new to server side scripting, then this can be a bit of a headache. ^^; So, there are a few things I would check. First, make sure and try running the apt-get commands in this tutorial again. Next, if that doesn't help, try making a file called "test.php" with the following in it..

<html>

<head>
<title> PHP Test Script </title>
</head>
<body>

<h1>TEST</h1>
<?php
phpinfo( );
?></body>

</html>

You should see a header saying "TEST" and then bunch of information in this page. If this works, than you should be able to rule out there being a server config problem. If you don't see anything, try sshing into your Pi and then looking at logs. (Usually at /var/log/apache2/error.log ) If logs aren't there, check to see where they are in your php.ini file. Really, you should see something.

It's also important to note that, if you are trying to use Database functionality with your webserver you must make sure that you have the apropriate connector. (For instance, if you use mysql, you have to do "apt-get install php5-mysql." A lot of php based applications just show up blank and white without any errors if you are trying to use the database but it can't connect.

I hope this helped someone!

Doesn't work.

jriach5 months ago
Really great instructable, thank you!
I'm new to this and hope this doesn't sound like a silly question but you mentioned needing to set permissions to access phpMyAdmin from my laptop and I'm getting the error 'you don't have permission to do this'.
Could someone shed a little light on this please?

Thank you!

Jamie
1-40 of 191Next »