hosting a website on a raspberry pi ?


38 posts   Page 1 of 2   1, 2
by blobert123 » Thu Jun 07, 2012 3:31 pm
I was wondering if after setting a pi up as a server i could then host my / my parents website ? Is this possible and are there any programs to (easily ) make a website on linux ? (my mum needs to be able to update her website regularly ) she currently uses notepad and html !! so something graphical and simple would be good :-) thanks
Posts: 13
Joined: Wed May 23, 2012 6:48 pm
by mpettitt » Thu Jun 07, 2012 8:45 pm
You could do this, but it would require a decent internet connection speed (don't forget that most connections are faster for downloads than uploads, and web servers mostly upload data), and you'd have to leave the Pi running as a server most of the time, rather than playing with it, which seems a far worse penalty!

What you're probably after is a basic CMS, which will allow updating from a web browser. Popular choices for these include Wordpress and Drupal. In order to run one of these, you'll need to set up a http server on your Pi (Apache is the internet's most popular one, but something a bit less resource intensive such as nginx might be better on the Pi), a database server (MySQL is the popular choice, SQLite would probably be a good Pi choice, if the CMS you use supports it) and a scripting language (PHP, Python, Perl...). See viewtopic.php?f=27&t=7457 for some options!
Posts: 8
Joined: Sat Jun 02, 2012 10:09 pm
by jbeale » Thu Jun 07, 2012 9:43 pm
The Pi is good for low complexity, low-bandwidth websites. If you're currently authoring in notepad, it's likely you have a low-complexity site! As mpettitt pointed out, it will be limited by whatever outgoing bandwidth you connect to it.

I know some ISPs offer bargains for a COLO (co-located onsite) server if it uses less power than normal. The Pi at about 2 watts is very efficient!
User avatar
Posts: 2076
Joined: Tue Nov 22, 2011 11:51 pm
by SN » Thu Jun 07, 2012 10:05 pm
it definitely can be done - you need to have the following:-

- simple web server (such as lighttpd) running on your pi
- a (reasonably) static IP address from your ISP
- a static internal IP address for your pi (or DHCP allocation via MAC address)
- on your router have inbound port forwarding set up so that port 80 is forwarded to your pi's internal IP address
- a domain name would be good too that can be pointed at item 1 one the list

All of that I have sat behind http://www.bryxx.com 8-) a simple one page demo site (at the moment)

FOOTNOTE - and if you want to see where people are coming from and how often to your site, sign up for Google Analytics - fantastic solution
Right now 23:21 on 7th June there's someone from Ireland and Norway looking at my site 8-)
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1008
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by sharix » Sat Jun 09, 2012 2:03 pm
can you post some instructions SN? I tried to install lighttpd but I got this error: http://redmine.lighttpd.net/boards/2/topics/5179
Posts: 171
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia
by SN » Sat Jun 09, 2012 2:21 pm
the clue is in this error line in your log
Code: Select all
chown: invalid group: `www-data:www-data'

I believe (I hacked it differently I think) the cleanest thing to do is that you need to create a www-data group (use addgroup command) and www-data user (use adduser command) in that group BEFORE doing an apt-get install lighttpd
Should all be OK then.

Website file location can be found at /var/www
You need to visit the /etc/lighttpd/lighttpd.conf file and add in the features you want (such as cgi-bin and logging)
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1008
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by sharix » Sat Jun 09, 2012 10:24 pm
Yeah, this fixed those errors.
I set up a basic website but now php doesn't work. I have installed php5.
Posts: 171
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia
by sharix » Sat Jun 09, 2012 11:52 pm
Can't edit a post, so:
php actually works, but only if a whole page is a .php
if there's some php code inside a .html page then php doesn't work.
Posts: 171
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia
by RussIT » Sun Jun 10, 2012 12:27 am
I think (but don't quote me on this) you can have php and html in a .php page but only html in a .html page.
Posts: 28
Joined: Thu Jan 05, 2012 11:34 am
by pfyon » Sun Jun 10, 2012 3:09 am
I actually moved my blog over to my Raspberry Pi, primarily so people can see the performance of it running a webserver. It's running wordpress on lighttpd with the mysql database running on the Raspberry Pi itself.

Surprisingly, the slowness doesn't seem to be caused by mysql, more so fastcgi.

http://peterfyon.homeunix.com
Posts: 1
Joined: Sun Jun 10, 2012 3:05 am
by sharix » Sun Jun 10, 2012 11:31 am
Okay I solved the php problems by simply changing all .html extensions to .php
Posts: 171
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia
by marcelp1 » Mon Jun 11, 2012 8:56 pm
SN wrote:the clue is in this error line in your log
Code: Select all
chown: invalid group: `www-data:www-data'

I believe (I hacked it differently I think) the cleanest thing to do is that you need to create a www-data group (use addgroup command) and www-data user (use adduser command) in that group BEFORE doing an apt-get install lighttpd
Should all be OK then.

Website file location can be found at /var/www
You need to visit the /etc/lighttpd/lighttpd.conf file and add in the features you want (such as cgi-bin and logging)


Hi all,

great site, with loots of info. I am newbie.

Have followed the install process and something gone wrong this is what I get if I try to
remove it in order to reinstall lighttpd from here
http://www.debian.org/doc/manuals/debia ... -dpkg.html


root@raspberrypi:/home/pi# apt-get remove lighttpd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
lighttpd
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 897 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 51261 files and directories currently installed.)
Removing lighttpd ...
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "stop" failed.
dpkg: error processing lighttpd (--remove):
subprocess installed pre-removal script returned error exit status 127
configured to not write apport reports
insserv: warning: script 'K01lighttpd' missing LSB tags and overrides
insserv: warning: script 'lighttpd' missing LSB tags and overrides
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "start" failed.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
lighttpd
E: Sub-process /usr/bin/dpkg returned an error code (1)


root@raspberrypi:/home/pi# dpkg -r lighttpd
(Reading database ... 51261 files and directories currently installed.)
Removing lighttpd ...
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "stop" failed.
dpkg: error processing lighttpd (--remove):
subprocess installed pre-removal script returned error exit status 127
insserv: warning: script 'K01lighttpd' missing LSB tags and overrides
insserv: warning: script 'lighttpd' missing LSB tags and overrides
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "start" failed.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
lighttpd
root@raspberrypi:/home/pi#

Thank you in advance for any advice.
Posts: 115
Joined: Mon Jun 11, 2012 8:41 pm
by RicardoRix » Tue Jun 12, 2012 4:36 pm
yes you can, a guide for this setup:
http://rix.uk.to/RasPi/RasPi2HeadlessWebserver.html
Posts: 1
Joined: Sat Jun 02, 2012 6:28 pm
by marcelp1 » Tue Jun 12, 2012 8:23 pm
marcelp1 wrote:
SN wrote:the clue is in this error line in your log
Code: Select all
chown: invalid group: `www-data:www-data'

I believe (I hacked it differently I think) the cleanest thing to do is that you need to create a www-data group (use addgroup command) and www-data user (use adduser command) in that group BEFORE doing an apt-get install lighttpd
Should all be OK then.

Website file location can be found at /var/www
You need to visit the /etc/lighttpd/lighttpd.conf file and add in the features you want (such as cgi-bin and logging)


Hi all,

great site, with loots of info. I am newbie.

Have followed the install process and something gone wrong this is what I get if I try to
remove it in order to reinstall lighttpd from here
http://www.debian.org/doc/manuals/debia ... -dpkg.html


root@raspberrypi:/home/pi# apt-get remove lighttpd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
lighttpd
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 897 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 51261 files and directories currently installed.)
Removing lighttpd ...
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "stop" failed.
dpkg: error processing lighttpd (--remove):
subprocess installed pre-removal script returned error exit status 127
configured to not write apport reports
insserv: warning: script 'K01lighttpd' missing LSB tags and overrides
insserv: warning: script 'lighttpd' missing LSB tags and overrides
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "start" failed.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
lighttpd
E: Sub-process /usr/bin/dpkg returned an error code (1)


root@raspberrypi:/home/pi# dpkg -r lighttpd
(Reading database ... 51261 files and directories currently installed.)
Removing lighttpd ...
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "stop" failed.
dpkg: error processing lighttpd (--remove):
subprocess installed pre-removal script returned error exit status 127
insserv: warning: script 'K01lighttpd' missing LSB tags and overrides
insserv: warning: script 'lighttpd' missing LSB tags and overrides
.: 18: Can't open /etc/rc.d/init.d/functions
invoke-rc.d: initscript lighttpd, action "start" failed.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
lighttpd
root@raspberrypi:/home/pi#

Thank you in advance for any advice.



Managed to solve it.

Edited the script /etc/init.d/lighttpd and placed in one of
the first lines "exit 0;"
Posts: 115
Joined: Mon Jun 11, 2012 8:41 pm
by LetHopeItsSnowing » Thu Jun 14, 2012 5:55 am
1 quick comment, if you ISP doesnt provide you with a static IP addres (mine doesnt) you could consider using a dynamic dns service like www.no-ip.com.

I set this up using my Pi to host a podcast and it works a treat, see http://stuffaboutcode.blogspot.co.uk/2012/06/raspberry-pi-access-from-internet-using.html for how to get no-ip running and installing the client.

LHIS
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"
User avatar
Posts: 210
Joined: Sat May 26, 2012 6:40 am
Location: UK
by Jock in a Frock » Thu Jun 14, 2012 7:27 am
LetHopeItsSnowing wrote:1 quick comment, if you ISP doesnt provide you with a static IP addres (mine doesnt) you could consider using a dynamic dns service like http://www.no-ip.com.

I set this up using my Pi to host a podcast and it works a treat, see http://stuffaboutcode.blogspot.co.uk/2012/06/raspberry-pi-access-from-internet-using.html for how to get no-ip running and installing the client.

LHIS
If using a Dynamic DNS service, check out your router, many have an option to subscribe to a DynDNS service, so the updating is handled by your router, not your Pi (or another client on your LAN). One less thing to worry about.
Posts: 72
Joined: Thu Jan 12, 2012 6:39 pm
by LetHopeItsSnowing » Fri Jun 15, 2012 5:50 am
Jock in a Frock wrote:
LetHopeItsSnowing wrote:1 quick comment, if you ISP doesnt provide you with a static IP addres (mine doesnt) you could consider using a dynamic dns service like http://www.no-ip.com.

I set this up using my Pi to host a podcast and it works a treat, see http://stuffaboutcode.blogspot.co.uk/2012/06/raspberry-pi-access-from-internet-using.html for how to get no-ip running and installing the client.

LHIS
If using a Dynamic DNS service, check out your router, many have an option to subscribe to a DynDNS service, so the updating is handled by your router, not your Pi (or another client on your LAN). One less thing to worry about.


My router does support a couple of dns services, but both charged and being notoriously tight, I installed no-ip simply because its free!
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"
User avatar
Posts: 210
Joined: Sat May 26, 2012 6:40 am
Location: UK
by czayen » Thu Jun 21, 2012 10:20 am
Hi, I have a problem with hosting WordPress site on my Pi.

It's running Debian "squeeze" with Apache2, PHP, and MySql.
Everytime I navigate to the site for the first time after reboot it works fine, until I try something more like logging on to the back-end or changing the theme. It basically freezes the Raspberry so bad that I can only reboot it, or sometimes I can manage to killall5 to get it back to normal.

I have tried reinstalling it completely and also tried my SD card with my friend's Pi - with the exactly same results.

I'm also running phpmyadmin and webmin on it and there is no problem when using those. It seems like there is a problem with WordPress only.

Any ideas what is might be?
Posts: 2
Joined: Thu Jun 21, 2012 9:53 am
by chrisfo » Fri Jun 22, 2012 9:33 am
I've had exactly the same experience this week. Wordpress is perhaps overkill for my requirements so I am currently looking for more lightweight options for the entire 'stack'. When it works it was all pretty slick but the lockups were too frequent for the overall solution to be usable.
Posts: 1
Joined: Fri Jun 22, 2012 9:30 am
by eeyore.t.mule » Tue Jun 26, 2012 6:04 am
SN wrote:it definitely can be done - you need to have the following:-

- simple web server (such as lighttpd) running on your pi
- a (reasonably) static IP address from your ISP
- a static internal IP address for your pi (or DHCP allocation via MAC address)
- on your router have inbound port forwarding set up so that port 80 is forwarded to your pi's internal IP address
- a domain name would be good too that can be pointed at item 1 one the list

All of that I have sat behind http://www.bryxx.com 8-) a simple one page demo site (at the moment)

FOOTNOTE - and if you want to see where people are coming from and how often to your site, sign up for Google Analytics - fantastic solution
Right now 23:21 on 7th June there's someone from Ireland and Norway looking at my site 8-)


ah a local user ;)
(well sort of local when I'm back at my house in reddish... I'm up in barrow as I type... :lol: )

When i'm back at weekend my first project will be a micro web server. Prob running wordpress, might turn it in to a micro blog... :!: :roll:
Donkeys like Pi
Posts: 10
Joined: Mon Jun 25, 2012 4:40 pm
Location: Stockport or Barrow
by LetHopeItsSnowing » Tue Jun 26, 2012 7:57 am
A few people have experienced problems with the Pi crashing out under heavy load and again a few people have had good results by re-compiling the kernal. Search on google for raspberry pi recompile kernal and you will find a few tutorials (its no where near as scary as it sounds!)

LHIS
"am I getting slower, or is stuff more complicated; either way I now have to write it down - stuffaboutcode.com"
User avatar
Posts: 210
Joined: Sat May 26, 2012 6:40 am
Location: UK
by Squiffy » Sat Jun 30, 2012 10:23 pm
Someone create a Raspberry Pi colocation lol
Posts: 14
Joined: Sat Jun 30, 2012 9:11 pm
by Zekta » Mon Jul 02, 2012 9:26 am
There are couples of ways of getting this done...
e.g. LAMP (Linux + Apache + Mysql + PHP), or lighttpd / pure php etc

PI will run better in the light weight solutions, but the procedure are much more complex.
And it depends much on what to be setup.
E.g. if you expect a fully running CMS, you'll need a DB, which will probably consume lots of memory of the RAM PI offered.

If you can keep thing simple, you can put on a lighttpd with static html files. (or Octopress for generating them for advanced user)
If you want some fancy thing, you'll need a CMS (Probably php based) such as Drupal / Joomla / Wordpress which are the popular choice, but getting mysql/sqlite run would be tricky.

In the case of database solution, I would strongly suggest you to do that on a external USB HDD (with external powered USB Hubs).
The reasoning is that the flash media will decay quickly if you have lots of writing. Running a DB on the same flash with your OS is the last thing you want. :?
Posts: 2
Joined: Mon Jul 02, 2012 9:14 am
by dktucson » Thu Jul 05, 2012 1:31 am
Absolutely possible..mine is up & running at http://dktucson.dyndns.info:86 . I installed apache and bluefish web editor. Downloaded a freebie canned template--edited it accordingly in Bluefish. Configured apache to listen to port 86 and forwarded port86 to the Ipaddress of the pi (port 80 is already used by another webserver in the house). I used a pre-existing dyndns account I've had since their free days :)
Posts: 36
Joined: Tue Jun 12, 2012 2:57 am
by BakaOsaka » Thu Jul 05, 2012 12:33 pm
I'm gonna pitch in and say that I have one running on my Pi at http://bakaosaka.no-ip.org/ (Usually only during daytime though) and it has PHP added. Because of this, I added a neat little server info page!
User avatar
Posts: 40
Joined: Tue Jun 12, 2012 11:30 am