loading
Picture of Host your website on Raspberry pi
Raspberry pi is a low cost development board by the raspberry foundation,for this tutorial i am using the distro provided by adafruit that can be found at http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v0-dot-2 all you need to do is download the image and use WIN32 disk to burn the image on to the SD card. This tutorial is very different from rest and focuses on hosting a site from raspberry pi and make it accessible ONLINE (from anywhere in the world).
 
Remove these adsRemove these ads by Signing Up

Step 1: Connect via SSH

Picture of Connect via SSH
putty-config.PNG
loginpi.PNG
Now connect your raspberry pi to home router using a Ethernet cable. the ada-fruit image comes with SSH enabled so you can connect via SSH immediately.

now you should try to open a SSH session via putty to raspberrypi.local or the speccific IP address( if you have ur HDMI connected it should be there on you screen, or go to ur router config page(usually 192.168.0.1) and check for raspberry pi under DHCP). you can log in to the raspberry pi with user name :pi and password :raspberry.

Step 2: Setting up you rasberry pi

Picture of Setting up you rasberry pi
reboot.PNG
once you have a new installation there are a few things you should do to get things going, that includes expanding your root file system to fit the entire memory card and changing the user name and pasword. executing
sudo raspi-config
will take to to the config page where you can configure your PI.

Step 3: Installing your server

Picture of Installing your server
Now you have to install a server on the raspberry pi, the easiest is the Apache Server (Lighttpd also works if you are looking for something lighter) run the following commands to install Apache, PHP5, PHP5 mod for apache and MYSQL( if you are planning to use a CMS or a database.

sudo apt-get update

sudo apt-get install apache2 php5 libapache2-mod-php5


now you should allow overrides by editing the 000-default file, you can do that using the following comands..

sudo nano /etc/apache2/sites-enabled/000-default

now edit the following lines

change "AllowOverride None" -to "AllowOverride ALL".

now execute 

sudo service apache2 restart

to restart apache witht your new settings

now your site should be up and running u can go to /var/ and change the permissions on www, making it writable.

cd /var/
sudo chmod 777 /www


this will enable you to login using WINSCP and upload HTML pages to your new site. open the browser on your PC and point to 192.168.xx.xx (ip address of you raspberry pi) to view the default page.

You can also install and SQL server using the following comands, with a PHP and SQL running on your server u can have a CMs like Drupal running on it.

sudo apt-get install mysql-server mysql-client php5-mysql

Step 4: Setup up PORT triggers

Picture of Setup up PORT triggers
Now you should have your server running, go to raspberrypi.local or the ip address from your browser on your PC and you should see the default apache page.
This means your server is up and running.
Now the problem is there is no way to access this website from the internet (like if your friend in Mexico wants to see the site :-(  ).
so go back to your router config page and set the port triger as shown in the picture below. this tells the router if there is someone trying to send an HTTP request via port 80 forward the traffic to the raspberry pi. This make the raspberry pi accessible from the internet.

Step 5: Have your domain name

Picture of have your domain name
add-host.PNG
supersite.PNG
no-ipconfig.PNG
Now you have a website that can be accessed from online, but most of you (like me) dont have a static IP (its too expensive), which means every 1day or so , your ISP might change your ipaddress(gateway) so you cant always type in the ipaddress and expect to see your website, so solve this we use a no-ip service that gets installed on the raspberry pi. This service runs on the raspberry pi and tells the no-ip server what your IP address is. No-IP gives you a domain name that will point to your last updated IP, all you have to do in make a free account at set and regiter you hostname it will look like (rspi.no-ip.org) you could also go for a premium domain name. once that is done, type in the following commands to install the service....

cd /usr/local/src/

sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

tar xf noip-duc-linux.tar.gz

sudo rm noip-duc-linux.tar.gz

cd noip-2.1.9-1/


sudo make install

after the install is finished, it will automatically start the configuration, enter the username and password of the no-ip.org to finish the installation.

now you have your server set up successfully now all you have to do is make sure it runs every time you start the raspberry pi. there a couple of ways to do this, this i feel is the most easy one.

cd /etc/
sudo nano rc.local


add the following line , in the rc.local file to make noip service run during startup
sudo noip2

ctrl-x 
to close the file and save the file.

now reboot the PI by the following comand

sudo reboot

Step 6: Visit you website

Picture of Visit you website
after setting up the no-ip service, you should be able to access the website hosted on your raspberry pi using the domain name you chose. You can test if the noip service is running by the following command.

sudo noip2 -S

if you see an valid PID, it means you have the service now running.... upload a few pages and hav fun!!
1-40 of 48Next »
SeAN152 months ago

So does this mean I can use my raspberry pi to have my web page online using my domain? I have a domain www.theridgeprogram.com/ so could I have my raspberry pi as the server instead of the paid web hosting, so everyone can see it?

DevB1 SeAN151 month ago

Yes, technically you should be able to do exactly that. Beware though that depending on the traffic your site receives, your pi and network connection may be overwhelmed. I found this fairy easy to do. Followed the steps given at

http://projpi.com/diy-home-projects-with-a-raspber...

SeAN15 DevB11 month ago

Thanks!

abel874 months ago

Nice!!!

Rumzi B4 months ago
JessicaH56 months ago

some packages, such as lighttpd and giving your Raspberry Pi a static IP address.

Pathfinder2166 months ago

I'm having problems transferring html files. I got all the way through restarting apache (after changing AllowOverride None to AllowOverride ALL). When I tried the "sudo chmod 777 /www" command (after changing the directory to /var/), however, it gave me the response "chmod: cannot access '/www': No such file or directory." I installed WinSCP and found the www folder and I confirmed that the default site displays properly. When I try to transfer files it says "Permission denied."

Does anyone know what's wrong and/or how to fix it?

Okay, obviously I'm new at this. I solved my problem by dropping the forward slash in front of "www".

sajingeo (author) 6 months ago

you can also check if your website is up and running by going opening midori browser on raspberry pi and typing in "localhost"

sajingeo (author) 6 months ago

when you are trying to access your website from the internet, check you internet IP address using google "what is my ip"(after you have setup port forwarding). you lan ip four computer is different from your WAN ip address of your router. To access your website make sure you enter the wan IP.

sajingeo (author) 6 months ago

if you have the no-ip service on you router you can skip step

sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

tar xf noip-duc-linux.tar.gz

sudo rm noip-duc-linux.tar.gz

cd noip-2.1.9-1/


sudo make install

sajingeo (author) 6 months ago

Hi, yes you should he storing the index.html in /var/www/ . Some routers have no-ip service that you can enable from your router admin page. also make sure you have edited apache config file to allow all IP, but default the server might only allow you local lan to access the website

NicolasT8 months ago

Hi! Thanks for the tutorial, but I am still running into a few hurdles. I followed every step. Just to make sure, I am supposed to upload my index.html file to /var/www right? I do have a PID running, but if I try to go to my website, it only shows "400 bad request". Do you think you could help me?

Yeah I have exactly the same issue!

Hey, did you ever fix your problem? I am giving another go at this, and although I can access everything locally with no problem, I can't see to put it online.

I ended up doing a different thing. Where I set up no ip on my router and then set up port forwarding (also on my router) in conjuction with my RP. Let me know if you need help. I also tried using pagekite but that can get quite expensive depending on traffic. Even though I would definitely recommend it if I was creating a test server or something... But I am using my server as a backup site which obviously uses a lot of traffic... Hope that helps...

I know how to do port forwarding and stuff (I think!), but I don't understand when you say you set up noip on your router. Can you explain that part?

ron.fechtner7 months ago

Hey! Nice and easy to follow tutorial!
But even tho I double checked every step, I still cant reach my content.

Calling the Pi's Local IP through an other device's browser displays the
index.html in the /var/www folder properly, but using either the global
ip or the no-ip.org domain results in a network timeout error.

- noip2 process is running (pid, current global ip and noip-domain is shown)

- 000-defaults file is edited ("None" to "ALL" - also checked "All")

- No-IP Website show pi's currend global IP and No-IP Domain aligned

- Port-Forward for Ports 80 and 21 for the Pi's local IP are enabled

Any further advice?!
Thanks in advance
Best regards and keep up the intuitive tutorials

Running Raspian tho...

I am having the same problem I have gone through another tutorial too: http://forum.xda-developers.com/showthread.php?t=2019600 which uses PageKite rather than No-ip but pagekite is really expensive! Please let me know if you find a solution!

Do you think it may be to do with port forwarding?

Jup I contacted my IPS.. It's because im using global IPv6 adresses with Dual-Stack Lite. Therefore my devices do not get a global IPv4 adress to enable Port Forwarding... They offered me to activate the IPv4 (real Dual-Stack) for an additioal monthly fee...

Isn't there any way to achieve the same goal with IPv6 enabled on the Raspberry?! (Except Portmapping expensive services)

Hey! I was wondering if you solved your problem? I think I am in the same situation. I can access my website on my local network but not on the internet...

Excellent tutorial! Now i would like to get some security to prevent some hacking activity. Where i can find some info about this? I thinks is installing SSL or something like that. Do u know any info about this? Thanks!

This is a very clear, complete, and easy to understand tutorial. Excellent work!

Hey can u plz send me that tutorial? Am not able to get it.

e-mail : rahulr25@gmail.com

sajingeo (author)  Doug Paradis1 year ago

thank you...

Hi all, now I start Raspberry Pi collocation in heart of Europe, more info find here: http://raspberry-hosting.com/ Enjoy !

Would there be anyway for me to use a domain name that I have already bought on GoDaddy?

sajingeo (author)  cheesecurd18991 year ago

Yes you should be able to do it, by editing your CNAME from your control panel and setting it to your HOME IP / no-ip domain name

rtdubbs sajingeo12 months ago

you’re referring to GoDaddy's admin area (or any other provider), correct?

rtdubbs12 months ago

completed without a hitch. fantastic! thanks!

Veziax1 year ago

I've done every step but when I type in my domain on Firefox it cannot connect... What's the problem?

sajingeo (author)  Veziax1 year ago

hi, is it working when you type in the IP address in the browser? is the Pi on the same subnet as your PC? did you edit the /etc/apache2/sites-enabled/000-default to allow all IPs

My /etc/apache2/sites-enabled/000-default allows all IPs (I changed "AllowOverride None" -to "AllowOverride ALL".) but it doesn't work.I don't wich subnet on my Pi is good so here's a pic

Subnet.PNG
Veziax Veziax1 year ago

I dont know wich subnet*

cyiangou22 years ago
hey, I am trying to run adafruit on my raspbbery but this is not respond.
Actually I download adafruit and used win32disk to write in in my SD card.
Then I put SD card in raspberry pi but its not respond. Why?
Thank you very much please help me
I had the same problem. It is the ram on the Pi. The adafruit image requires a Pi that does not have HYNIX ram. You can try to simply run any debian image for the Pi, since it has the enable SSH option during first startup and setup. Worked for me.
sajingeo (author)  cyiangou21 year ago

try another card, or check if the Lock swirch is enabled on the card

matthew99997 made it!1 year ago

Clear & concise instructions. I've previously tried to get my Raspberry Pi set up as a web server by following instructions I've found in a book I purchased and a different web site, but none ever worked. This one works great, thanks!

MaxPower.jpg
1-40 of 48Next »