Walters
About Me
Blog
2016
Ben
Ever sinceit's
introduction
early2012,
the Raspberry Pi has proven itself to be an extremely capable little machine. For less than
$30, you Walters
get a credit card-sized computer capable of automating home systems, powering robots, or even serving as a basic
desktop computer.
This tutorial however, focuses specifically on getting your Raspberry Pi set up to run as your very own web server. In addition, we'll
cover how to set up Dynamic DNS records, so you can access your sites/files even when you're away from your home network
13 Comments
Recommend
Share
Login
Sort by Best
MassivFotze
24 days ago
http://blog.peter-r.co.uk no longer loads up (404/403). Where do I go now to download the necessary files?
Great question! The quick answer is: Whatever you want! To be more specific, you can:
Ben Walters
Set up your own, private Dropbox-style cloud storage for your personal files/videos/images
Create a site that interfaces with your home security cameras and check them remotely
Host your own low-traffic webpages
Etc.
Beyond the web server-specific functions, a Pi with dynamic DNS set up can be used to:
Host your own Minecraft server (tutorial)
Run your own Git server (tutorial)
And much more!
Disclaimer: The Raspberry Pi is great as a lightweight web server for personal use and experimenting. However, if you are
interested in hosting a heavily trafficked site like a blog, I'd highly recommend hosting your content on a third-party web host. In
addition, most ISP's aren't particularly interested in letting their customers host their own web servers, and a self-hosted web server
with a lot of external requests can raise some flags and even slow down your home network connection.
Reply Share
Mod
Chris Pro
Reply Share
4 months ago
Ben, to reiterate what everyone else has said, great tutorial! I have one issue that I am not really clear on. I have two
name servers from cloudflare and they have been pending for two days now. You mention in the blog that "These will
need to be entered in your domain record in order to complete the transfer process" Being a complete noob I am
unsure where I need to enter these? Is it somewhere in the namecheap site? Appreciate any help here.
Reply Share
Ben Walters
Mod
I'm glad the tutorial was helpful to you! As far as entering the nameserver records in Namecheap is
concerned, I've updated the post to include more detailed instructions on that step.
Basically there should be a "Nameservers" section under your domain's settings in Namecheap that you
enter the Cloudflare-generated nameservers. Feel free to take a look and let me know if you have any more
questions!
The first step in setting up any new Raspberry Pi is to format an SD card for installing the Raspbian OS on. If you purchased/your
Pi came with a pre-formatted NOOBS SD card, you can skip these first few steps as your SD card already has Raspbian ready to
go.
Reply Share
For this step, you can choose to interact with your Pi directly using a USB mouse, keyboard, and monitor or SSH in via another
computer on your network (my preferred method).
NOTE: This would be a perfect opportunity to set a static IP address for your web server, so you can always access it at the same
local address. This can be done via your router's web interface.
Once you know the LAN IP address assigned to your new server, enter the following command in the terminal on your other
computer, making sure to replace the IP address accordingly:
ssh pi@192.168.0.106
You'll be asked for your root password (the one you set during the installation process, otherwise is "raspberry" by default).
OPTIONAL: If using the default password, you can change it by entering the following command after logging in with the default
credentials:
passwd
Reply Share
5 months ago
Hi Ben, thanks for the run-through. Near the conclusion, after testing
the configuration I did not receive a "Success." I got "Warning: unable
to determine IP address." Is there somewhere I have to manually enter
my Pi's IP address (other than ssh)?
Am I supposed to enter the API codes somewhere?
Reply Share
5 months ago
I figured our where I left out the API and think I figured out where the IP gets
entered at Cloudflare. But still no IP address in the test.
I did get this comment at the top when testing:
"WARNING: skipping host: web-dyndns: 'zone=' is an invalid fully qualified host name."
... I tried different forms for that value in /etc/ddclient.conf but couldn't get rid of the warning. Can you tell me
what form it should be in?
Reply Share
Ben Walters
To SSH, you'll need to determine the local IP address assigned to your Pi, which can easily be done by consulting your router's web
interface (http://192.168.0.1 for Netgear routers) and inspecting "Attached Devices". Look for "raspberrypi" in the description
column.
Mod
maddaddam
LAMP stands for Linux, Apache, MySQL, and PHP. It is a term commonly used to refer to a software stack for development and
deployment of web applications and web sites on servers.
4 months ago
Reply Share
Ben Walters
Once you've completed the Raspbian installation process, you can go ahead and plug your SD card into your Pi along with your
HDMI, Ethernet and USB mouse/keyboard. Fiinally, add some USB power to boot it up for the first time!
Ha! I was close but this narrowed it down perfectly. Again, a big thanks for taking the time to post an
amazing tutorial!
For those of you with brand new, unformatted cards, you'll want to follow raspberrypi.org's excellent guide to getting Raspbian
installed on your SD card.
NOTE: If your first Raspberry Pi boot completes without any prompts, it will eventually end you on the GUI desktop. To ensure SSH
is enabled from here, click "Menu" in the top left and navigate to "Preferences > Raspberry Pi Configuration". In the window that
opens, switch to the "Interfaces" tab and make sure "SSH" is set to "enabled".
Hey Chris!
Next go ahead and complete the Raspbian installation, making sure to enable SSH in the configuration process (great video
tutorial available here).
Thanks for the heads up! I've updated the post with a new source for the ddclient update. Please let me know
if you have any further issues!
Mod
Reply Share
Now that you're connected to the Pi, you'll want to update your Raspbian package list and install any new versions as necessary:
Reply Share
Mod
In my experience, those are the hardest errors to fix and the most annoying! But I'm
glad to hear you were able to get it working.
You're very welcome! If you continue to have issues, feel free to share. I'd be happy to
help!
Ben Walters
5 months ago
Thanks again for the tutorial. It's been a good learning experience, and hopefully I can make
use of it once it's up.
Once the Apache installation process has finished, you can go ahead and check to make sure your server is working by navigating
Thanks. In reading your reply and checking my ddclient.conf I noticed I had mis-typed
"use=web, web-dyndns". So it seems the dozens of checks and changes and web searches
and hours spent were unnecessary as the error just came down to a single typo. Haha.
Anyway, it's all working good now. The site still isn't live, however, I think the issues now are
with cloudflare and namecheap. If you're interested, I'll keep you updated.
OPTIONAL: By default, the full Raspbian image includes a number of extra features/libraries that most users won't need. You can
run a script (follow the instructions here) to optimize and remove these unecessary features and speed up the boot time of your Pi.
Note, this may take a while to run, so go grab a snack!
1
Barnaby Johnson Fry
Reply Share
5 months ago
pdfcrowd.com
Thanks for the tutorial! I'm interested in setting up my own Raspberry Pi Webserver, and I was glad to see your blog
post. My question is in regard to the Dynamic DNS Settings. You have provided directions for your DNS provider,
Name Cheap. I'm not using them, and I'm confused about how to proceed, unless I were to transfer my domains
over to their service, which I would rather not do. (FWIW, I'm a customer of namesilo.com). Do you have any advice
for setting up DynDNS?
Reply Share
Ben Walters
Mod
Hi Barnaby! I'm so glad my post has been helpful! As far as setting up DDNS with Namesilo, I don't have any
personal experience with their services. However, some quick searching suggests it's very possible.
It sounds like they have an API which will allow you to update your DNS records (overview here:
https://techjourney.net/update....
In addition, there's some documentation regarding the API specifically here: http://www.forkrobotics.com/20...
The API documentation I linked above is for Windows Powershell, but I think the information might be helpful,
nonetheless.
Feel free to post back your experience! I'm looking into switching my DNS provider in the future (heard good
things about Cloudfare.com).
pdfcrowd.com
previous provider. As a bonus, they offer all this in their free tier of service!
First though, if you don't already own a domain name you'd like to use, you'll need to purchase one. I recommend Namecheap. I've
been using their services for years and have had a great experience. However, feel free to use whomever you'd like!
Once you've got a domain name ready to use, go ahead and create/login to your Cloudfare account. Next, enter your new domain
name into the search field and let Cloudfare pull your domain records:
When the search is complete, click "Continue", confirm that all of your DNS records were successfully pulled and click "Continue"
again.
Next, you will be prompted to select what level of service you want to use. You can go ahead and select the "Free" tier:
You should be redirected to your Cloudflare dashboard and see something like the following:
There will be two nameserver records displayed. These will need to be entered in your domain record in order to complete the
transfer process.
To do this, simply log into your Namecheap account, navigate to your dashboard, and click "Domain List" on the left-side menu.
Click "Manage" on the domain for which you are transferring DNS control to Cloudflare, and enter the aforementioned nameserver
records under the "Nameservers" section:
pdfcrowd.com
After updating your domain record with the Cloudflare-provided nameservers, it should only take an hour or so to complete the
transfer (they say up to 48, but that's a generous estimate). Once it's done, you'll see the following on your Cloudflare dashboard:
Awesome! Your domain name record and DNS provider should now be configured and ready to accept DNS updates from your web
server.
Once you have your API key copied down, go ahead and enter the following command to open your ddclient configuration file for
editing:
sudo nano /etc/ddclient.conf
You'll need to change to the following:
use=web, web=dyndns
protocol=cloudflare, \
server=www.cloudflare.com, \
zone=yourdomainnamehere, \
login=yourcloudflareloginemail, \
password=yourcloudflareapikey \
yourdomainnamehere
Exit the nano editor and save your changes by pressing 'Ctrl + X', 'y', and finally 'Enter'.
To test our configuration, and set the initial values, run:
sudo ddclient -daemon=0 -debug -verbose -noquiet
You should see a list of debug commands followed by a "SUCCESS" line reporting that your server's current IP was set on your DNS
record.
pdfcrowd.com
pdfcrowd.com