mob-i-l
Posts: 267
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Google+ Twitter YouTube

Web Hosting Service on a Raspberry Pi for Students

Thu Feb 02, 2017 11:55 am

I would like to run a web hosting service on a Raspberry Pi. It's for a course in web development for senior high school students. They should be able to log in and upload files via SSH to their own account, but should not be able to access other students' files or directories, unless they make them public via chmod. They should have access to PHP, and MySQL, at least one separate database for each student. It would be great if the web hosting service had similar features as http://one.com/ , but it doesn't need e-mail. It is enough if it can be administrated by me using scripts (in Bash, Perl, Python, PHP, Node, or any other language), although an additional web GUI is no disadvantage. It would preferably run on Raspbian (Lubuntu 16.04 would also be OK), because it's what I'm most used to, and be installed using a script or deb-file.

It should be secure so that students or others can't hack it or cheat by looking at other students' solutions. I intend to run the web hosting service from home and it would be shut off when the students should sleep, and I could back up then automatically to a USB flash drive. It's also useful to see the progression of the students' works, by studying the backups. Backups could possibly be done using Git.

The course has about 30 students. Each student should have a quota so that not one student fills up the SD-card. It's just for teaching purposes, so they don't need to upload a lot of data.

On an earlier course I used one USB flash drive for each student with XAMPP. A Raspberry Pi Zero for each student is a possibility, but it's too expensive now. The course is not about installing LAMP in Mac OS X, so it should be easy to use for the students. Maybe the students doesn't have rights to install LAMP on their Mac.

Does anyone know about such a system?
Last edited by mob-i-l on Tue Feb 07, 2017 4:06 pm, edited 1 time in total.
Have Pi0&1A&1B&1B+&2B&3B&4B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… https://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://twitter.com/mobluse/ https://YouTube.com/MOBiL4u/

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Web Hosting Service on a Raspberry Pi for Students

Thu Feb 02, 2017 2:15 pm

Install apache2

Code: Select all

$ sudo a2enmod userdir
$ sudo service apache2 restart
$ sudo adduser yourusername
$ sudo mkdir /home/yourusername/public_html
Put your user's html docs in that directory.
Then to access the page:
http://yourdomainorIP/~yourusername

edit: You may need to chown and chmod to allow your users to modify that directory and still maintain security.

mob-i-l
Posts: 267
Joined: Sat Dec 29, 2012 2:45 am
Location: Lund, Skåne/Scania, Sweden
Contact: Website Facebook Google+ Twitter YouTube

Re: Web Hosting Service on a Raspberry Pi for Students

Mon Feb 06, 2017 2:18 pm

Thanks! It's a start.
Have Pi0&1A&1B&1B+&2B&3B&4B w/ Raspbian. Started w/ BASIC on ABC80&ZX81 then Forth, Z80… https://scratch.mit.edu/users/mobluse/ https://github.com/mobluse/ https://twitter.com/mobluse/ https://YouTube.com/MOBiL4u/

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Web Hosting Service on a Raspberry Pi for Students

Mon Feb 06, 2017 2:52 pm

To allow your students to login and upload/download files, install proftpd in standalone mode.
sudo apt-get install proftpd
then select standalone when prompted.

When a user logs in, it will put them into their home directory with the option to cd into the public_html directory. You will need to chown that directory to allow writes.

Return to “Networking and servers”