Raspberry Pi Web Server

 by drcurzon
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)
dale3h says: Oct 3, 2012. 5:41 PM
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 :)
drcurzon (author) in reply to dale3hOct 3, 2012. 11:29 PM
Hi there,
Thanks for posting this to help others :)
Daniel
shawn_the_beast says: May 22, 2013. 11:20 AM
I would like to point out that service was spelled wrong. I just noticed that when copying and pasting the code over ssh. this is not meant as a rude comment. Other than that worked out perfect with me!!!
shawn_the_beast in reply to shawn_the_beastMay 22, 2013. 11:23 AM
In step 9.
cmrodican says: May 7, 2013. 12:06 PM
i am also having this issue, and unplugging/restarting does not work... also, on step 4, i remove the # from "#send host-name "andare.fugue.com", and you say to change "andare.fugue.com" to anything i want, does it have to be with xxx.xxx.xxx, orwhat format should that be in? btw, thanks for this tutorial... it is really helpful. i am just stuck on this one thing. thanks
cmrodican in reply to cmrodicanMay 7, 2013. 12:07 PM
sorry... the issue i am having is that my Hostname does not work and I have to ftp to the ip.address.
cheycomm says: Apr 28, 2013. 4:14 AM
Nice tutorial, I found this very helpful and easy to follow.

I do have 1 question. Why wouldn't you use the SFTP supplied with the SSH protocol as opposed to installing an additional ftp server (vsftp)?
drcurzon (author) in reply to cheycommApr 28, 2013. 11:33 AM
Hi there,
Glad it was useful.
Honestly, I wasn't aware of the program (SFTP) until you mentioned it, I'll have a look into that.
Many thanks, Dan.
deborahb13 says: Apr 11, 2013. 8:43 PM
Thank you SO much for this tutorial, I just got my Raspi today and I am trying to figure out all the tricks :)
ethoma says: Apr 6, 2013. 5:26 AM
So far all is nice but I cant seem to connect to the raspberry with its hostname, only with the IP address. any hint on where the Problem is? the Router sees the Pi and its new host name but the browser cant.

all in all a very good Tutorial
drcurzon (author) in reply to ethomaApr 6, 2013. 8:37 AM
Hi there,
This is usually a router issue, which OS do you use at the moment?
Can you try a "ping" command (or equivalent) with the host name?
What's the output?
Many thanks, Dan.
neer0 says: Mar 29, 2013. 5:21 AM
What Permissions are to be changed while uploading admin using filezilla??
thecank says: Mar 4, 2013. 10:03 AM
I had two lines like this:
#send host-name "xxxxxxxx"
send host-name = gethostname()
I commented out the second one and changed the host name in quotes to raspberryPi then set it in the command line but I cannot connect to it via Putty (I still have to use the IP address)

Also in step 9, my vsftpd file is blank. Not sure what I'm doing wrong.
karnuvap says: Mar 3, 2013. 1:08 AM
Hi there - I'm afraid I am stuck on this a little bit.

I get as far as adding the # in the /etc/passwd file. However when I try to add pi as a mod it throws up the error that the user pi does not exist. Assuming this was the desired outcome, I try the last few steps and try to login as pi however it says access denied no matter how many passwords I try to enter for pi (the password for root, my chosen pi password and the default one - neither work).

This only seems logical, as I had just commented out the user pi in the previous file, surely?

Ignoring this set back, since it appears to be an optional step, I successfully connect to the FTP server but my FTP directory looks much different to the one in your screenshot despite being the same directory (/home/pi).

Any ideas? Thanks.
drcurzon (author) in reply to karnuvapMar 3, 2013. 6:10 AM
Hi there,
I think the distribution has changed since I wrote this.
Try leaving the user "pi" in as normal (Leave out the #).
Many thanks, Dan.
rbli63 says: Feb 27, 2013. 2:37 PM
Wouldn't it be better to use an FTP client that supports a user-settable default upload path (like for example Filezilla)?

You say:"At the moment you will need to change the directory every time you login by FTP", then some magic, concluded by:
usermod -d /var/www pi

I'm a Linux n00b, so please correct me if I'm wrong. The usermode -d changes the default home path for user Pi, right? That is, not only when logging in via FTP, but also when logging in via SSH, or anything else, right?

With Filezilla (and probaby many others) this is not necessary. But more importantly, I wonder whether or not the usermod is a good idea at all. I had the webserver up & running, no problem. But then I installed some more stuff, which then of course, landed in /var/www. Which looks a bit messy to me. It may be prone to hacking, I don't know.

Any learned comments?
drcurzon (author) in reply to rbli63Feb 27, 2013. 2:38 PM
Hi there.
Thanks for the comments.
As I understand it vsftp is a "thin" server, as in it doesn't use that much in the way of resources.
The better approach for vsftp is to use a dedicated FTP user and set that user's home directory to var/www.

Other than that, a server like FileZilla would be a good idea, I was just trying to use as little of the raspberry pi's few resources as possible.

As far as security, I don't believe that there would be any issues due to the user's home directory, however it is a good question.

Many thanks, Dan.
hamcircuit says: Feb 17, 2013. 12:03 PM
I tried adding that and I still just get a blank page still.
drcurzon (author) in reply to hamcircuitFeb 17, 2013. 12:33 PM
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.
hamcircuit says: Feb 17, 2013. 10:18 AM
Here is the contents of the index.php file. I can delete later so it does not take up so much space on page.

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* forms frameset
*
* or common.inc.php
* @package PhpMyAdmin
*/

/**
* Gets core libraries and defines some variables
*/
require_once './libraries/common.inc.php';

// free the session file, for the other frames to be loaded
session_write_close();

// Gets the host name
if (empty($HTTP_HOST)) {
if (PMA_getenv('HTTP_HOST')) {
$HTTP_HOST = PMA_getenv('HTTP_HOST');
} else {
$HTTP_HOST = '';
}
}


// purge querywindow history
$cfgRelation = PMA_getRelationsParam();
if ($GLOBALS['cfg']['QueryHistoryDB'] && $cfgRelation['historywork']) {
PMA_purgeHistory($GLOBALS['cfg']['Server']['user']);
}
unset($cfgRelation);


/**
* pass variables to child pages
*/
$drops = array('lang', 'server', 'collation_connection',
'db', 'table');

foreach ($drops as $each_drop) {
if (array_key_exists($each_drop, $_GET)) {
unset($_GET[$each_drop]);
}
}
unset($drops, $each_drop);

if (! strlen($GLOBALS['db'])) {
$main_target = $GLOBALS['cfg']['DefaultTabServer'];
} elseif (! strlen($GLOBALS['table'])) {
$_GET['db'] = $GLOBALS['db'];
$main_target = $GLOBALS['cfg']['DefaultTabDatabase'];
} else {
$_GET['db'] = $GLOBALS['db'];
$_GET['table'] = $GLOBALS['table'];
$main_target = ! empty($GLOBALS['goto']) ? $GLOBALS['goto'] : $GLOBALS['cfg']['DefaultTabTable'];
}

$url_query = PMA_generate_common_url($_GET);

if (isset($GLOBALS['target']) && is_string($GLOBALS['target']) && !empty($GLOBALS['target']) && in_array($GLOBALS['target'], $goto_whitelist)) {
$main_target = $GLOBALS['target'];
}

$main_target .= $url_query;

$lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][1];


// start output
require './libraries/header_http.inc.php';
?>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
xml:lang=""
lang=""
dir="">



phpMyAdmin <?php echo PMA_VERSION; ?> - <br /> <?php echo htmlspecialchars($HTTP_HOST); ?>



echo PMA_includeJS('jquery/jquery-1.6.2.js');
echo PMA_includeJS('update-location.js');
echo PMA_includeJS('common.js');
?>


drcurzon (author) in reply to hamcircuitFeb 17, 2013. 11:44 AM
Hi there,
Can you add the following to the top of the page:

echo "test";
die();

and try that - you should see "test" on screen when you go to the page.
Thanks, Dan.
hamcircuit says: Feb 16, 2013. 11:15 AM
Permissions are 775. I am typing in 192.168.1.110/admin
do not see a admin.php?
Thanks
drcurzon (author) in reply to hamcircuitFeb 16, 2013. 11:31 AM
Sorry, meant index.php (admin/index.php)
hamcircuit says: Feb 6, 2013. 10:10 AM
Hello, I have install all but have run into a problem. When I type the pi.ip/admin all I get is a blank page in the window. I have change all the permissions so that I can get in. Not sure were I need to go to from here. Thanks
hamcircuit in reply to hamcircuitFeb 16, 2013. 10:38 AM
Can anyone help me with this problem?
hamcircuit in reply to hamcircuitFeb 16, 2013. 10:58 AM
i am able to open the website at just the ip address but when I try to bring up the php it just bring to a blank page. I have changed all permissions to 775. I am using PHP 3.5.7 and wheeze. Hope this will bring some info.
drcurzon (author) in reply to hamcircuitFeb 16, 2013. 10:47 AM
Hi there.
What are the permissions of the page?
What is the URL you are typing in? (including page)
What is the content of admin.php?

Many thanks, Dan.
jansonap says: Feb 9, 2013. 7:11 AM
For me, when i set permissions to "var/www" from the command line it did not apply them recursively to all sub folders and files. Easiest way to do this is if you have FileZilla opened right click on the "www" folder and click "File Attributes". Type 755 into the numeric value if not there already then check "recursive into subdirectories". Click "OK". Now try and access the admin page again.
spafruit1 says: Feb 8, 2013. 8:26 AM
At stap 7 Type in "sudo apt-get update" i get always a connection timed out at 69%. Any tips?
spafruit1 says: Feb 8, 2013. 3:03 AM
At stap 9 you say :
Now restart the FTP server with "sudo servce vsftpd restart"
but i think it must be:
Now restart the FTP server with "sudo serivce vsftpd restart"
drcurzon (author) in reply to spafruit1Feb 8, 2013. 7:42 AM
Hi there.
Thanks for that, yeah it should be "service".
Many thanks, Dan.
Robbanz says: Feb 6, 2013. 12:52 PM
Well something with "reply" is bugging out...

@Dan thanks for your answer.
I just reainstalled Everything and now it works (must have missed something after all)...

Now is my next problem that i can't portforward port 1433 and 3306 for MySql and MSSQL... but that's Thomsons fault NEVER buy a TG789VN...
Robbanz says: Feb 3, 2013. 2:20 PM
Hi, i have followed all step without any errors and i have port 80 opened in my router but when trying to log in to http://raspberrypi/admin/phpMyAdmin

i get below error
Forbidden
You don't have permission to access /admin/phpMyAdmin on this server.

Does any one have any idea about what can be wrong?
drcurzon (author) in reply to RobbanzFeb 3, 2013. 11:23 PM
Hi there.
What have you set the permissions for the files as?
Can you access any other page you've got on the pi?
Many thanks, Dan.
jstemm says: Jan 30, 2013. 8:23 PM
I believe there is a missing (perhaps extra?) step when commenting out the "pi" line in /etc/passwd. What you may chose to do is copy that line, such that you have the line repeated twice. Then comment out one of the lines.

'usermod -d /var/www pi' changes the user's home directory from the default (/home/pi) to the directory /var/www. This will alter the line in the /etc/passwd file. Copying the original line and commenting it out essentially keeps a "backup" of what the line used to say.

That's what I'm assuming anyway, and is what I did. When you FTP using your username and password, you are directed to /var/www immediately. Hope that all makes sense.
prusux says: Jan 29, 2013. 3:04 AM
Same here. After adding "#" to the pi line under /etc/passwd there is no possibility to start a new session as pi user. maybe there is a different line needed as this pi user is just uncommented and does not exist for the system.. sooo after searching the web there is a "solution" in the youtube (lol) http://www.youtube.com/watch?v=zXxWncOxAWk

Anyway, i do not think that this is a popper solution. Please correct this manual :) Thanks!

munderwood4 says: Jan 22, 2013. 7:32 PM
I'm following along fine, but I'm kinda of stumped on this step: "usermod -d /var/www pi"
After commenting out the /etc/passwd line, the above command doesn't find the username pi. I also can't create a new ssh session as pi. Did I miss something?
the_number says: Jan 20, 2013. 12:21 PM
Cant get the reply-function to work, anyways:
The answer to my problem is here: http://forums.debian.net/viewtopic.php?f=30&t=50502
You need to change the ownership of the folder to "www-data". I have no idea what means, I´m still new to to linux, but that solves it.
drcurzon (author) in reply to the_numberJan 20, 2013. 11:18 PM
Hi there.
In case you still need help (looks like you beat me to it :) ) to change the owner of a directory the command is "chown".
For example "chown www-data /home/pi/apache".
Hope this helps, if not then let me know :)

Thanks, Dan.
the_number says: Jan 20, 2013. 11:02 AM
First of all, thank you for your in depth tutorial!

After successfully setting up apache in the default configuration, I wanted to change the root directory to "/home/pi/apache". Changing the respective configurations in the 000-default file I get a "403 - Permission denied" error.

I have tried everything I could find on google - I changed both the "DocumentRoot = PATH" and "", the later once with quotation marks and once without. I have also done "chmod -R 755 PATH" for the directory itself and all it´s parents.
Here is a good summery of what I tried: http://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/

However none of this had any effect. I have also read that something called "selinux" might interfere, but from what I understand it is not installed on raspbian.

Does anyone have successfully changed their DocumentRoot? Any ideas on what is causing the issue?
mchild3 says: Jan 14, 2013. 11:27 PM
When you used this method, "apt-get install phpmyadmin"? how did you log in to the admin page?
drcurzon (author) in reply to mchild3Jan 14, 2013. 11:33 PM
On a LAN connected computer, navigate to
"http://RASBERRYPI IP/phpmyadmin"
Many thanks, Dan
mchild3 says: Jan 13, 2013. 11:34 PM
apt-get install phpmyadmin
had a go at running the above line as I couldn't get the phpadmin to run in a web browse.

Doing the above I still can't get it to run, when I look on the ftp it appears to be in

/var/lib/phpmyadmin

where as I was expecting to see it in /var/www/admin

where am I going wrong?
jwilliams991 says: Dec 16, 2012. 6:35 AM
How do I upload the website onto the pi and then access it? Also can you do sudo apt-get install phpmyadmin??
jscott22 says: Dec 9, 2012. 10:26 PM
Great Instructable. I would recommend adding a bit more information about what each step is actually doing.

My thinking is that Raspberry Pi is targeting students/beginners who will benefit from understanding WHY they are running apt-get update, what the mySQL server is used for, etc.
postpawl says: Nov 23, 2012. 5:01 PM
why not use "apt-get install phpmyadmin"?
drcurzon (author) in reply to postpawlNov 23, 2012. 11:57 PM
Hi there.
It's just personal preference. I Prefer to have all of the web files accessible in the var/www directory as it saves time when editing a lot of different files.

However "apt-get install phpmyadmin" may have been easier for some people to understand.

So like I said, just personal preference.
Many thanks, Dan.
danpea says: Nov 23, 2012. 8:09 AM
This bit of you instruction is puzzling me:-

Now navigate to where you installed phpMyAdmin (for me it's http://raspberryPi/admin)

All the step previous to this went ok but how can you navigate to http://raspberryPi/admin remotely ?

Am i missing something?

I can ssh into my pi remotely and have copied over all the phpadmin stuff using an FTP client but from here on i am stuck.

drcurzon (author) in reply to danpeaNov 23, 2012. 11:54 PM
Hi there.
What I meant was to use a web browser on another computer on the same LAN to connect to the raspberry pi.
Hope thIs helps, if not then let me know.
Many thanks, Dan.
karbono says: Nov 18, 2012. 4:13 PM
Hi. Thanks for the tutorial. Maybe you could help me with my router. I configured port forwarding, but I'm having no luck accessing my RPi through any port (vnc, ftp or http). I tried a small web server on my PC and no luck either, so I guess it's a router issue.
Things to note: If I try opening my external IP through my browser, I get the router's configuration page. Apparently that only works from inside my network, since I asked a friend to open the page and he just saw an error page.
Another thing: If I try using WINSCP with the external IP, I get a "computer actively denied the connection"...
I'm lost, right now... My router is a Huawey b260a (http://www.manualowl.com/m/Huawei/B260a/Manual/257649)

I tried changing ports to no avail...
Any help is deeply appreciated
hamcircuit says: Nov 4, 2012. 6:06 PM
Hello, this is a great instructable. I am having a problem thoe. When i try to login to my php is tells me that i do not have permission. Could someone help me with correcting this. Everything else seems to be working as listed.
Thanks
drcurzon (author) in reply to hamcircuitNov 5, 2012. 4:00 AM
Hi there.
What is the URL that you're being redirected to?
Have you tried changing the database login details?
Dan
hamcircuit in reply to drcurzonNov 5, 2012. 7:38 AM
I am logging into 192.168.1.127/php which is the folder that I copied the php files to. It does not redirect me it just gives me a 402 forbidden. I am not sure were the database login details are at. I am able to get to the ftp and the web page and log in through ssh
drcurzon (author) in reply to hamcircuitNov 5, 2012. 11:05 AM
Hi there.
What are the permissions settings for the web page?
They should be 755.
Thanks, Dan.
m.christian says: Oct 30, 2012. 3:14 PM
Hi, I've come stuck when trying to login in to phpmyadmin. I get the following error "Phpmyadmin error. The mysqli extension is missing" I can get access to the webserver and edit the index file and it all works but can't get access to myadmin. Any help would be awesome.

Cheers,

Matt
tedlawson says: Oct 28, 2012. 4:06 PM
Everything great up to the last instruction.
Could not open (for me): http://192.168.1.91/admin?
xzerix says: Oct 24, 2012. 3:05 AM
How does the host name thing work?

I can connect using putty but have to give the IP address (192.168.0.98) to connect. Once connected and logged in, I can type "hostname" and the reply is "raspberrypi" but I can't connect as raspberrypi, only 192.168.0.98 - What am I being dumb and missing, please? :(
drcurzon (author) in reply to xzerixOct 24, 2012. 3:40 AM
Hi there.
If you're using windows, open cmd and type in:
"ping raspberrypi".

Mac:
Go to Applications > Utilities > Network Utility.
Click on the Ping tab and type "raspberrypi" as the host name. Then click ping.

Linux (desktop):
Open terminal and type "ping raspberrypi".

Let me know what the output is. Dan.
xzerix in reply to drcurzonOct 24, 2012. 11:20 AM
I'm using windows 7 (64Bit)

ping raspberrypi returns "Ping request could not find host raspberrypi. Please check the name and try again."

My PuTTY session looks like the screenshot (prompt is pi@raspberrypi:~$) although I connect as 192.168.0.98 (i.e. top of screen says

login as: pi
pi@192.168.0.98's password:

typing hostname returns raspberrypi

the line in /etc/dhcp/dhclient.conf is:
send host-name "raspberryPi";

(capital P, same as yours...)

Really scratching my head because I've done everything twice and it's still off :(

The IP number is assigned by the router (i.e. reserved address of 192.168.0.98), if that's what causing the problem?

Any help greatly appreciated :)
drcurzon (author) in reply to xzerixOct 24, 2012. 1:08 PM
Hi there.
What router are you using as it may be set to not allow host name connection?
xzerix in reply to drcurzonOct 24, 2012. 1:33 PM
It's a SKY router - a Sagem F@ST2504

xzerix in reply to xzerixOct 24, 2012. 2:16 PM
D'oh...

http://helpforum.sky.com/t5/Sky-Broadband-Setup-Cabling/New-Sagem-Router-host-name-problems/td-p/365775

Looks like it's a known issue with the router.

Thanks for pointing me in the right direction :)
xzerix in reply to xzerixOct 24, 2012. 11:40 AM
The plot thickens - ping -a 192.168.0.98 should return a host name - it doesn't...
willq44 says: Oct 20, 2012. 8:34 AM
when i try to access it it said forbidden and i don't have permission and cant access any files or folders
wwoomy says: Oct 9, 2012. 1:14 AM
Step 8 "sudo apt-get install mysql-server mysql-client php5-mysql", failed to install.....HELP! T__T

121009 7:46:38 [Note] Plugin 'FEDERATED' is disabled.
121009 7:46:38 InnoDB: The InnoDB memory heap is disabled
121009 7:46:38 InnoDB: Mutexes and rw_locks use GCC atomic builtins
121009 7:46:38 InnoDB: Compressed tables use zlib 1.2.7
121009 7:46:39 InnoDB: Using Linux native AIO
121009 7:46:39 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
121009 7:46:39 InnoDB: Completed initialization of buffer pool
121009 7:46:39 InnoDB: Fatal error: cannot allocate memory for the buffer pool
121009 7:46:39 [ERROR] Plugin 'InnoDB' init function returned error.
121009 7:46:39 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
121009 7:46:39 [ERROR] Unknown/unsupported storage engine: InnoDB
121009 7:46:39 [ERROR] Aborting

121009 7:46:39 [Note] /usr/sbin/mysqld: Shutdown complete

[FAIL] Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up php5-mysql (5.4.4-7) ...
Setting up mysql-client (5.5.24+dfsg-9) ...
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.

dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for libapache2-mod-php5 ...
[ ok ] Reloading web server config: apache2.
Errors were encountered while processing:
mysql-server-5.5
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
wwoomy in reply to wwoomyOct 9, 2012. 1:25 AM
I removed the installation......though some of them cannot be removed....

pi@raspberrypi ~ $ dpkg -l | grep php5-mysql
pi@raspberrypi ~ $ dpkg -l | grep mysql-server
iF mysql-server-5.5 5.5.24+dfsg-9 armhf MySQL database server binaries and system database setup
ii mysql-server-core-5.5 5.5.24+dfsg-9 armhf MySQL database server binaries
pi@raspberrypi ~ $ dpkg -l | grep mysql-client
ii mysql-client-5.5 5.5.24+dfsg-9 armhf MySQL database client binaries

**the main problem should be that it fails to start the mysql database server....any suggestions how to fix it? thanks!
wwoomy in reply to wwoomyOct 11, 2012. 2:50 AM
solved...

solution::

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=19277&p=191839#p191839
fivetricks says: Oct 7, 2012. 7:59 AM
Great tutorial! One of the most detailed instructions in this wild DIY world!

I'd like to leave a suggestion: to use nginx instead of Apache. nginx is very light and has a simpler configuration. I think it fits better in Raspi's limited configuration. Also, the more you avoid unneccessary CPU usage with heavy applications, less heat is produced by the processor, so, the more your Raspi will last!

Regards,
RStaden says: Sep 30, 2012. 11:43 AM
Great tutorial but I am struggling with making the PI online. I can access it internally on the network and have set it up as these steps instructions. I can access my router and it has options for port fowarding. On adding a port forwarding the options are Operation, interface, protcol, public port, local port and local IP. Any advice on this would be great. Also how do I get an IP on the PI?
drcurzon (author) in reply to RStadenOct 3, 2012. 11:26 PM
Ports 80, 443, 21 need to be port forwarded to your raspberry pi's internal up address in your router. This will allow for apache web server, https web server, FTP to connect externally.

I believe the command is "ifconfig" to view the iP address on the pi, although I'm not sure as I'm away at the moment with no access to a pi.
Daniel.
drupopuppis says: Sep 25, 2012. 5:16 PM
Amazing tutorial, I have followed step by step and I am now running my server on raspi. The only thing that I have to figure out is how to port forward my router so that I can have access to my raspy from outside the home network.

by the way, one more thing, I am still unable to use the "hostname", instead I am using the PI internal IP.

Thank you for the great work.
drcurzon (author) in reply to drupopuppisSep 25, 2012. 11:23 PM
Hi there.
The host name issue is possibly caused by your router setup, so well deal with that in a bit.
With regards to accessing the pi over the Internet, please note that you should setup a firewall on the pi first.
What type of router do you have?
You need to setup port forwarding of ports:
80 - apache web server
443 - apache https server
21 - FTP
They need to be forwarded to the raspberry pi's internal up address.
If you don't know how to do this, let me knOw what type of router you have, and I'll try to help. Daniel.
drupopuppis in reply to drcurzonSep 26, 2012. 1:15 AM
Hi Daniel,
Thanks for the quick reply, my router is a sagecom 2504FA@STn my ISP is sky.
I remember opening a port for an IP camera, I guess this should be similar with the difference that more services have to be created and different ports assigned. Does the internal IP for the three different services, (Apache, FTP, MySql), change or it remains the IP for the raspberry Pi?
wdsparrow says: Jul 30, 2012. 9:53 PM
Hello folks, I'm getting what I believe to be a permissions issue using IE FTP client to drag drop files to the folder with the index.htm file exists. (Sorry not familiar with the right terminology.) I have used this method on other linux servers before so I'm guessing I have an apache permissions issue? Can someone give me directions on how to give my pi user write access?

Here is the error...
FTP folder Error

An error occured copying a file to the FTP Server. Make sure you have permission to put files on the server.

Details:
200 Switching to Binary Mode.
227 Entering Passive Mode (192.168,0,197,138).
553 Could not create file.
wdsparrow in reply to wdsparrowJul 31, 2012. 5:21 PM
I found it. I apparently missed a step.

Very thorough directions. Wonderful instructable.
davidov in reply to wdsparrowSep 10, 2012. 2:16 PM
Hi!
I have the same error (553 Could not create file) but I cannot find what I skipped during the FTP setup.
Could you help me what was the reason for you to receive this error?
Thank you.
drcurzon (author) in reply to davidovSep 10, 2012. 11:42 PM
Hi there. Have another look at step 9. THis appears to be a permissions issue. Try the following command.
"sudo chown -R pi /var/www"
Let us know how you get On. Daniel.
drcurzon (author) in reply to davidovSep 10, 2012. 11:38 PM
Hi there. This is most likely to be a permissions issue with the server files. If you run "chmod 755 -R /var/www" this should clear it up. However I'd have another look at Step 9 Incase you accidentally missed a part of it out.
Let us know how you get on. Daniel.
davidov in reply to drcurzonSep 11, 2012. 11:14 AM
Thank you for the quick respone!
Yes, that was the problem! Although I remembered issuing this command, I had to do it again. Im not sure what i did wrong... Great tutorial anyways!
wscottsanders says: Sep 2, 2012. 8:09 PM
Thanks for putting together a great tutorial. I've never really used linux so I'm just following along. However, I'm afraid that I'm stuck when it comes to getting putty and the raspberry to talk to one another. I'm getting a "Network Error: Connection timed out" error. I'm pretty sure this is just my setup and not you're instructions but I was hoping you might be able to give me a bit of a hint to get me over the hump.
drcurzon (author) in reply to wscottsandersSep 2, 2012. 9:48 PM
Hi there,
Are you trying to connect via hostname or ip?
Could you please post a copy of the connection info (excepting the password) that you are trying to connect with?
Many thanks, Daniel.
wscottsanders in reply to drcurzonSep 2, 2012. 11:48 PM
Thanks for getting back with me. I figured it out. I'm very, very green at this and I didn't have the port forwarding set up properly. I'm still trying to get it working but at least rasppi is communicating now! Thanks.
drcurzon (author) in reply to wscottsandersSep 3, 2012. 10:21 AM
No problem, glad to see that you got it sorted :)
Daniel.
wscottsanders in reply to drcurzonSep 8, 2012. 2:51 PM
Got it up and running! I just had a quick suggestion. Since there are people like me (who have little linux experience) following along it might be a good idea to show us how to mount an external usb hard drive or flashdrive so we can take advantage of the FTP. Otherwise, this was great and I really enjoyed it!
grunge41 says: Sep 8, 2012. 4:14 AM
Great, followed it with ease and got my raspberry pi up and running in no time, may thanks.
paulware says: Aug 9, 2012. 10:57 PM
For some reason my Hostname does not work and I have to ftp to the ip.address. Any suggestions? I tried hostname newName
drcurzon (author) in reply to paulwareAug 10, 2012. 1:56 PM
Hi there,
Have you tried restarting the Raspberry Pi, unplugging it, starting it, plugging it back in then restarting it?
That may help, if not - let me know.
Daniel.
paulware says: Aug 9, 2012. 9:39 PM
When you say remove the "#" symbol from in front of it. Should I also change "andare.fugue.com" to be the new host name?
drcurzon (author) in reply to paulwareAug 10, 2012. 1:51 PM
Hi there,
Yes - replace "andre.fugue.com" with anything you want - No spaces allowed, and only some special characters will work :D
Daniel
cyrilgp says: Aug 1, 2012. 6:12 PM
Thanks a lot for this very detailed instructable. I am yet to buy a Raspberry, but wanted to head a head start on knowing how things works and understand.
CE_REAL says: Jul 27, 2012. 3:34 PM
Hello,

I'm having trouble setting up the FTP part from:

At the moment you will need to change the directory every time you login by FTP, to solve this:

I do get to set the password for root, but do you mean "exit", "exit" to use as a password?

Then I don't get the part:

find the line "pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash" and change it to "#pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash".

In my "/etc/passwd" file it has this line uncommented. So I comment is as you say, but then I won't be able to connect to the device again? Because after commenting, this command:

"usermod -d /var/www pi"

Say the user "pi" doesn't exist. And root is only temporary.

So my question is where did I go wrong? Even if I still have the "pi" user active, I can't connect to the FTP using FileZilla.
drcurzon (author) in reply to CE_REALJul 28, 2012. 3:20 AM
Hi there,

Exit is to log out of the Pi, you can type anything you want as a password - just make sure to remember it :D

Now close the SSH session, and start a new one - this time logging in as the root user, with the password you just set.

Now type "nano /etc/passwd" then hold the CTRL key and press W.
Type "pi" and hit return. It should show you 2 entries.

One of those entries must be commented out to work.

Save the file, then type "usermod -d /var/www pi" then Return/Enter.

then "passwd pi" and set a password.

Finally try connecting via FTP again.

Hope this helps, if not - ask again and I'll try and help :D
Daniel.
CE_REAL in reply to drcurzonAug 1, 2012. 6:38 AM
Thanks, I got it to work now.

But now I have another problem, I get the following error when creating a new folder or file:

No space left on device

Now I get what is causing this, my partition doesn't have enough space:

Filesystem Size Used Avail Use% Mounted on
rootfs 1.8G 1.7G 0 100% /
/dev/root 1.8G 1.7G 0 100% /
tmpfs 19M 212K 19M 2% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 37M 0 37M 0% /tmp
tmpfs 10M 0 10M 0% /dev
tmpfs 37M 0 37M 0% /run/shm
/dev/mmcblk0p1 56M 34M 23M 61% /boot

Above is my usage, and it shows I've used all the 100% of the rootfs and /dev/root, but I don't know what this is.
I'm trying to add folders to my /var/www/ folder, is that also in there?

And I'm using a 16Gb SD card, so how can it be full already with these sizes. Does it have to do something with the formatting of the SD?

I formatted it on Windows with FAT32, don't know what cluster size, maybe I have to change that?

I hope you can clear this up for me.

Thanks in advance.
drcurzon (author) in reply to CE_REALAug 1, 2012. 1:44 PM
Hi there,
The issue is easily solved by the following instructable:

http://www.instructables.com/id/Raspberry-Pi-Resize-Partitons-Use-all-free-space/

It's because the image is set to, I believe, 1 or 2 GB. The above instructable will walk you through the process to resolve this.
Hope this helps, Daniel.
rok0191 says: Aug 1, 2012. 10:04 AM
Hi, really great tutorial! It works for me for the first time and this is my first experience with linux.
I only have a problem with transfering phpMyAdmin files over ftp. There is no problem with connecting to Raspberry Pi, but I cannot copy any files on it. It writes that operation failed. I think that it is problem with permissions, but I am not sure and I can`t solve this problem.
Does anybody know what should I do?

Thanks for help!
Paul-Adrien says: Jul 24, 2012. 8:37 AM
I'm sorry to bother, but could anyone tell me how to set permissions to copy the PHPmyAdmin files?
Thanks
drcurzon (author) in reply to Paul-AdrienJul 24, 2012. 10:11 AM
Hi there,
What exactly are you trying to do - copy the PHPMyAdmin files from where to where? I'd be happy to help.
Daniel.
Paul-Adrien in reply to drcurzonJul 25, 2012. 11:00 AM
Thanks, I just can't understand step 10, I can't get File Zillia to copy the files from my computer to the raspberry pi all the tranfers fail.
Thanks again,
Paul-Adrien
drcurzon (author) in reply to Paul-AdrienJul 25, 2012. 11:02 AM
Hi there,
What is the error you are getting with filezilla?
Daniel.
miicchhii says: Jul 21, 2012. 1:55 AM
Thanks! thats great!
Already running at: http://langeder.no-ip.org/cms/index.php?p=raspberry-pi-server
pawelsky says: Jul 15, 2012. 10:47 AM
"sudo servce vsftpd restart" should be "sudo service vsftpd restart" :)
Computothought says: Jul 10, 2012. 8:32 AM
Where do you get a raspberry pi without waiting forever?

Might save some time or at least typing.
sudo tasksel install lampserver
sudo apt-get install phpmyadmin
dkeating2 says: Jul 5, 2012. 4:48 PM
I setup mine at http://dktucson.dyndns.info:86 the pi runs headless with just a USB wireless fob & a power cable--vnc server starts at boot. I installed apache , used my existing dyndns account and just specified port 86. Opened that up on my router and forwarded it to the pi's IP addrss. Edited the ports.conf and sites-enabled file. Downloaded a stock template and unzipped it to /var/www. Then used bluefish on the pi to edit the webpages--great little project...also configured an IRC server on it
thekendall says: Jul 4, 2012. 6:31 PM
So I want to make a webserver and raspberry pi sounds like a good solution but my question is how can I connect it to the internet securely. I am scared that adding my server to my home network will compromise the entire network, Is this true? Should I buy a separate modem?
drcurzon (author) in reply to thekendallJul 5, 2012. 1:40 AM
Hi there,
In my experience, if you set the port forwarding to the Raspberry Pi, and install a firewall on the Raspberry Pi with correct rules, then the network should be safe.
Also a firewall and antivirus is usually a good idea for all of the computers on the network anyway.
As far as firewalls go, I'd say that UFW is a pretty easy one to understand, or there's iptables which is a lot harder to understand, but gives you much more flexibility and control.

To conclude, with a firewall installed, your netowkr should be perfectly safe. (as well as choosing strong passwords for stuff like SSH, FTP, etc)

Hope this helps, Daniel.
paswicka says: Jul 2, 2012. 5:16 PM
upate in 'Type in "sudo apt-get upate" should be update
drcurzon (author) in reply to paswickaJul 3, 2012. 2:34 AM
Thanks for the correction :D
dlemke1 says: Jun 27, 2012. 6:52 PM
Ok thanks it works =)
but where can i change the Http file it loads?
drcurzon (author) in reply to dlemke1Jun 28, 2012. 9:12 AM
Hi there,
After step 9 - Install an FTP server, you will be able to connect to your Raspberry Pi via FTP.
You can use a client such as Filezilla (freeware) to do this.

The details will be:
Hostname: hostname you set
Username: pi
Password: password you set.

Once you've connected via FTP you'll be able to view, update and delete files on the server.
Assuming you've covered all of step 9, the directory you connect to should be /var/www and you'll see an index.html file.
Change these to what you want and it'll work fine.
Hope this helps, Daniel.
dlemke1 says: Jun 25, 2012. 3:24 PM
Every time i type 'sudo service apache2 restart' i get

Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName .

My dhcp-hostname is 'goddyserver'

Any advices ?
drcurzon (author) in reply to dlemke1Jun 26, 2012. 12:12 AM
Hi there,
This isn't an issue - it won't stop it working. It's due to it looking for a name it cannot find.
There's no need to worry about this, as your Apache 2 installation should still work okay.
Hope this helps, Daniel.
adream608 says: Jun 15, 2012. 7:00 AM
nice setup

i have been running a raspberry pi server for a week or so, very stable, although its ethernet.
i tried setting up wireless but it was't reliable enough for a server
for real world pi speed test follow the link below, its served in the UK on a standard adsl line.

mmmmm pi ! :-)

http://adream.homeunix.com/
bigme says: Jun 7, 2012. 7:58 AM
I must know where you you purchased, or how you made that case! Pi was delivered on Monday, and sitting on the TV stand is not safe enough with two cats around here.
Thanks
drcurzon (author) in reply to bigmeJun 7, 2012. 8:19 AM
Hi there,
I used a laser cutter to make the case - I'll put the CAD files up soon.
The case actually has a fan that can easily be slotted on top in case you want to overclock it.
HPIM2749.JPGHPIM2751.JPG
RCS82 says: Jun 4, 2012. 7:34 AM
Very informative. I've been thinking about setting up one of these servers for a while, but was waiting because I was planning on using an old Desktop and I had forgotten how to set up these programs and was putting it off, also forgot about Raspberry Pi being released.

Thanks. I'll be picking up a Pi when I get a chance.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!