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 ads by
Signing UpStep 1: 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)













































Visit Our Store »
Go Pro Today »




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 :)
Thanks for posting this to help others :)
Daniel
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)?
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.
all in all a very good Tutorial
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.
#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.
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.
I think the distribution has changed since I wrote this.
Try leaving the user "pi" in as normal (Leave out the #).
Many thanks, Dan.
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?
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.
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.
/* 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');
?>
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.
do not see a admin.php?
Thanks
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.
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"
Thanks for that, yeah it should be "service".
Many thanks, Dan.
@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...
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?
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.
'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.
Anyway, i do not think that this is a popper solution. Please correct this manual :) Thanks!
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 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.
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.
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?