Hi guys, Those who have been looking for a nice, easy way to get a website up and running on a dedicated server might want to consider the Raspberry Pi. Even though this device only costs around $35 and it is technically a beta or an experimental machine, it has some impressive potential that could make you host your current website host. While it might not have the same power and capabilities as a real dedicated server from a prominent host, you actually can use your Raspberry Pi as a dedicated web server. Of course, you will have to think smaller in scale. Let’s look at what the Raspberry Pi offers to see whether it is something that you might want to try.
What Can the Raspberry Pi Do?
Hmm… Why would you want to choose this option for your dedicated server? Most people have gotten away from the idea of having their own machines act as dedicated servers and instead, they are looking toward using the cloud. In some cases, that’s perfect. However, using this device as your own dedicated server can be helpful too. Of course, it doesn’t apply to all situations. Well, if you have a relatively small company and site, then it can work out very well for you. However, it does have some limitations.
The Raspberry Pi can store and host a simple website, and it can allow you to save your files in the cloud. However, the critical word here is that your website will be easy or simple. You won’t have a massive online store, tons of interactive features and the like when you use this device. However, you can still set up a decent, respectable website with it. They can use simple HTML as well as more advanced web apps.
When you are setting up your website and using the device for a dedicated server, it is generally in your best interest to do it as simply as possible. Having a few web pages without too much to tax the machine is a good idea. Best of all, you can do this without any monthly hosting fees. You will also be able to create just about any look you want for your site. They are great for some small sites and the like, but you really must realize that they are not going to be a business solution for you. Instead, they are a fun and simple way of putting up some files online and to experiment.
Think about the amount of traffic that you have coming into your website right now. While a Raspberry Pi server might be capable of handling the traffic right now, you will find that it’s not always going to be the case. The current generation of the device, as capable as it is, still is not as powerful as your average home PC. It will be on your network, and it simply won’t be able to handle a large amount of traffic. If you have it on your home network, and you are suddenly getting a substantial amount of traffic, you might find that you are actually unable to get onto the web because of how busy your network is. That would not be very good for business.
Another one of the problems is that many of the web hosts out there have clauses built right into their contracts that disallow you hosting your own dedicated server. While they would not have any problem with a small server and a very small project, it’s not something that you want to use as your main business website. It simply wouldn’t work.
What can you do with the Raspberry Pi server then? Quite a few things, actually. You are still able to use if for a small, personal site. For example, you could create a website of family photos and a family history that is specifically for you and your family members to use. You could also create your own storage space for files. Maybe you want to store a large number of photos, or even some audio and video files. It can work quite well for that.
How Easy Is It to Set Up?
One of the great things about the Raspberry Pi is it is relatively simple to use. Having knowledge of servers, operating systems, and building websites are essential though. Even though it is easy, you will need to know the basics first. Also, keep in mind that it is not going to be ready to play website host when you get it. Let’s look at what you will need.
You need to make sure that you have your own router and modem that you will get from your ISP. Just because you aren’t paying for a host for the site, you will still need to pay for your own Internet connection. You will also need to have an Ethernet cable, which you will hook up from the router to the device so that it has a permanent connection to the web. You need an operating system for your device as well, not to mention SSH, or secure shell, access. Choose the one with which you are most comfortable. A popular choice is Raspbian.
Once your system is up and running, you will want to install Apache web server software. This is a very favorite option and is the one that many server owners utilize. In fact, estimates are that about 50% of sites hosted on servers are running Apache. When you install Apache, it will also install PHP. With that installed, you can set up your own website.
Keep in mind that to do this, you are going to need to know how to build websites in HTML or PHP. There are not going to be any templates that you can simply download and use. After all, this is your own site and server. You are building from scratch. For many, this is quite liberating. They can create what they want. For others though, it can actually be intimidating.
One question? How do you turn a Pi into a machine competent of hosting websites? You do what other server maintainers have been doing since the earliest days of the Web—you install Apache Web server software.
When I say Apache is a Web server, I mean it’s a program that listens for server access requests from Internet browsers and grants them if permitted. So if you want anyone to be able to access a website on your Raspberry Pi—including yourself—you need to install a Web server.
The name is a play on “patchy,” since its creators were always patching the software to fix problems. It’s gotten a lot better since those early days, though. Apache is a free, open-source HTTP (Hypertext Transfer Protocol) Web server application. When you type a URL into your Web browser, a Web server somewhere replies by serving up a Web page. Apache is famous for these purposes: Roughly 50 percent of sites are hosted by servers running Apache.
Fortunately, this is a one-step process. Go to the command line and type:
sudo apt-get install apache2 php5 libapache2-mod-php5
This prompt accomplishes several things all at once. It installs the latest version of Apache, the server we need to use. It also installs two other packages: PHP and a library that helps Apache work together with PHP.
For a basic HTML site that remains static and doesn’t have many features aside from text, you do not need PHP. But if you ever want your site to connect to a database, you’ll need a web framework. PHP is a Web framework that adds more functionality to basic HTML websites.
For example, if you wanted to install WordPress on your Raspberry Pi hosted site, you’d need to make sure you could install at least one database.
When Apache is finished installing, restart it with this command to activate the program:
sudo service apache2 restart
Making A Basic Website
As soon as the Raspberry Pi finishes processing the above command, it instantly generates a basic, working website.
Go to your Web browser and type in your Pi’s local address. This will look something like 192.168.X.X. (If you haven’t obtained that address already, see my instructions on using the sudo ifconfig command to get it.) A very simple website should appear, headlined with the phrase, “It works!” This simple index.html page came preinstalled along with Apache.
Want to tweak it? Visit the index.html page on your Pi:
sudo nano index.html
Try changing the words around, saving the file, and navigating back to the Pi’s local address again to watch your changes take form.
Getting It Online
You can access and edit your website, but it’s only visible to you on your local network. That’s a good thing—you don’t want it to be this easy for people to access the Internet in your home!
So how do you get your Web server on the actual Web, not just your local network? Think about the way the Internet reaches into your home. Your ISP gave you a box that serves as the router. When you access the Internet, your request goes through your router to the Internet, and then back through the router back to your computer.
More technically, the ISP is sending the request back to port 80, the default port for HTTP requests. Or as we know them, Web-browsing requests.
Our goal is to have requests come from the Internet and go through the router to our Pi.
The problem? We’ve got lots of devices at home—computers, tablets, cell phones, to name a few—aside from the Raspberry Pi. Trying to direct traffic to just the Raspberry Pi, out of all your devices on the network, would be like sending a letter to a person who lives in an apartment complex without specifying the apartment number. The mail would be returned to its sender.
And that’s not the only problem. We’ve got to consider that in many cases, the router comes equipped with a built-in firewall, a security system that controls inbound and outbound traffic. Usually, the goal is not to have people from the Internet access your home network. But this time, we want to punch a Raspberry-Pi-shaped hole in the firewall for traffic to get through.
Luckily, there’s one solution to both problems: we forward port 80 to something else. If we say the Raspberry Pi is at, for example, port 8080, the router will send the traffic there.
In my examples, the numbers 22.214.171.124 are just mimicking the numerical pattern of URL requests. Usually, you request a URL by typing in a domain name; this is just how the computer reads it. We’ll go over converting our IP addresses into human-readable domain names in a few more steps.
A Forwarding Order For Your Pi
This next step will depend on the type of router you have and may differ depending on that particular router’s software.
Here are some port forwarding tutorials for major router manufacturers:
This is the most independent part of the tutorial, so you might be asking yourself, “What happens if I skip this and just assign a domain name to the Raspberry Pi’s IP address?”
I tried this, and it’s possible. But don’t expect your ISP to allow it for very long.
Just for kicks, I tried skipping the port forward and applying a domain name to my Raspberry Pi’s IP address. Since I could identify its IP address as unique from the other devices on my network, there should be no problem, right?
Wrong. My ISP, Verizon, blocked access in fewer than 60 seconds. That’s probably because it judged that I was doing something unwise. I warned you earlier that your ISP will forbid activities that it thinks are against its terms of service.
When malicious bots crawl the Web, sometimes they’ll ping port 80 by default, just to see if they can get access. In response, some ISPs will block inbound traffic to port 80 by default. Verizon didn’t want me to make a website accessible at port 80 because it’s the standard. When using any other port, however, Verizon hasn’t given me any trouble.
Getting Yourself A Domain Name
Now, people can access your site from anywhere—if they know your Raspberry Pi’s external IP address. But most people are accustomed to writing a domain name request in actual words.
Fortunately, there are free services you can use to translate your IP address into a domain name. I use DNSdynamic most frequently, so my instructions will reflect that service.
Sign up for DNSdynamic, and secure an available domain, which will look something like “example.dnsdynamic.com.”
DNSdynamic will helpfully tell you your current external IP address. I’ve blurred mine out for safety; you don’t want to share this with people. But instead of your own IP address, you’ll want to fill in the Raspberry Pi’s external IP address, which you’ll have secured after the port forward.
Now you’ve got a human-readable domain name that forwards to the Pi’s IP address.
And you’re done! Share your domain name with friends or family or anybody you’d like to be able to access your site. Just don’t get too popular—because if your Pi gets too much traffic, you’ll have to do some explaining to your ISP.
What’s the Best Option for a Business Site?
While it is relatively easy to set up a server with a Raspberry Pi, it is easy to see that it really is not an ideal choice when it comes to any sort of business site, even if you are a small business. It is too difficult to try to ensure that the traffic is going to the right place. Businesses shouldn’t use these as their own dedicated servers. Instead, take the time to look for a professional web host who is capable of providing your company with dedicated servers that are the size and power needed. Whether you are using a physical server on your property, or you are using a cloud server, it needs to have power, flexibility, and expandability to work for a business.