The Raspberry Pi Series: Taking Your LAMP Server Online

2020. 11. 16. 09:01Raspberry Pi

반응형

 

 

 

Hello friends, Babae here! 

By now, you should have a Wordpress blog that is accessible from your local area network (LAN) by typing in your local IP address in the web browser’s address bar. If you have not gotten this far, please go back and read the previous part of the series.

 

This week, we will be continuing the series by taking your LAMP server online so anyone can access your Wordpress blog on the internet. 

Now, one of the key steps is to set the forwarding port on your router. If you don’t know how to access your router’s settings and make the change, you will have to Google that on your own. This is also where we begin. 

Go to your router’s settings and find the ‘port forwarding’ page. We will now add a port forwarding rule: 


Application name: HTTP 

Public: 80 

Private: 80 

Protocol: TCP 

Local IP Address: <Your Pi’s IP address> 


Application name is irrelevant, and your router might not even ask for it. It is just for you to identify what the entry is for. The public port 80 is what we are listening for. Like I mentioned in a previous post, data is communicated through a port using either TCP or UDP protocol. Port 80 is used to identify HTTP traffic. When a HTTP request comes into your router, your router will need to know what to do with it. In the settings above, we set for the incoming traffic on pot 80 to be forwarded to your Pi because that is where your Apache server is. If you don’t have Apache set up, then your Pi wouldn’t know what to do with the HTTP request. With Apache set up, the server will then be able to serve the webpage requested. 

A basic schematic of the process described above looks like this: 

 

Client device’s web browser -> HTTP request -> domain name server -> your public IP -> your router -> your Pi -> Apache -> your website


We will now add another rule to your port forwarding settings for HTTPS (S is for secure): 

Application name: HTTPS 

Public: 443 

Private: 443 

Protocol: TCP 

Local IP Address: <Your Pi’s IP address> 

As each port is used for a specific purpose or protocol, port 443 is used for HTTPS traffic. We will later use HTTPS to secure your Wordpress blog. 

Now, you can access your Wordpress blog by typing your public IP address into the browser from any device on the Internet. To find your public ip, you can Google "what is my ip".

 

The next step is optional but highly recommended. You need a domain. You can set up a free one with noip.com but the one I use is a paid one from Google Domains. 

This is not an advertisement for Google but there are many features that other domain providers do not provide. I have also been using my domain with Google since 2011, which offered free Google Workspace (previously known as G Suite). With Google Workspace, I can use gmail with myemail@mywebsite.com. That email will also be my account for all of Google’s other products. Managing the domain is simple too with the console provided. 

If you already have a domain, or you just obtained one, you need to go to the add a synthetic records. As your public IP may change periodically, depending on your Internet service provider (ISP), you need to point your domain to your public IP. You may ask your ISP to give you a static public IP but they will ask you why and there’s not easy explaination. And before you try, just know that most residential Internet plans prohibit hosting web services. This step, just like with the router, you will have to Google how-to on your own as every company is different. You will add a Dynamic DNS. When you do, you will then hopefully be given instructions to update the records. This will usually involve setting up an app on any device on the same network as your Pi or the Pi itself. With my Google Domain, I created a script where I would ping a web address given every hour to update my IP. 

If you have completed the steps in configuring your Dynamic DNS correctly, you should be able to use your domain to access your Wordpress blog. 

If you just set up your website without securing it, visitors will get a warning upon landing on your page telling them that you website is not secure. The warning is annoying but more importantly, your website is not secure. To ensure traffic between your client and your Pi is secure, you will need to obtain an SSL certificate.  

The final step is to set up Certbot. SSH into your Pi and type in the following command: 

sudo apt-get install python-certbot-apache

sudo apt-get install python-certbot-apache 


Certbot will now install and you will then run it to obtain a certificate: 

sudo certbot –apache 

sudo certbot –apache 

When prompted, choose to permanently redirect your HTTP traffic to HTTPS. 

That’s it! Now, you should have a Wordpress blog accessible from the Internet!

 

Next week, we will install Kodi and a plugin to watch Korean content.

반응형