Repository navigation
nginx runbook
This is the main part of this runbook. Because I initially setup my Raspberry Pi to serve my website.
I mainly followed this documentation https://www.pestmeester.nl/ so i am not going to copy paste everything here. I will just highlight the key points, the changes i have made and the caveats.
Oh and I will go only for the web server part in this tutorial, I won't recommend to try to setup your own mail server, well you could do it for the challenge (I actually did) but it would not be realistic in a production environment. The main reason is that nowadays due to spam fight, the main mx servers (google etc.) will not accept the emails from a non-approved mx server. So you might be able to receive emails (proven that the raspberry pi online 24/7) but for sending email you might be disappointed. I'd recommend you to use an alternative on the market, which unfortunately are not cheap but can also handle email in a secure way (encryption etc.) like proton mail. if you don't want to spend money I'd recommend mailgun trial account (https://www.mailgun.com) which might do the jobs if it is only for your personal use.
Follow the step in [Base-Configuration]
If you need more space than the space available in your SD, you will have to follow the procedure "Setting up your USB Drive" section
- How-to connect securely using SSH Keys from your SSH Client.
Follow instructions at linode.com
- ssh Daemon configuration
Following instruction at base-configuration
- Installing and Configuring Fail2Ban
Following instruction at base-configuration
- Firewall (iptables)
iptables configuration is documented in iptables-config
- Add your user to www-data group:
$ sudo usermod -aG www-data severin
Ok we are good to proceed with the installation of web server components.
ok, here is a slight difference with the tutorial from https://www.pestmeester.nl/.
I want to install latest version of nginx available for Raspbian/Debian 8 (jessie) in the jessie backports, currently nginx/1.10.3, and not the one from raspbian/debian 8 (jessie) stable repository (nginx/1.6.2). To do that, we are going to install nginx from jessie-backports
here is how-to use the backports on your raspbian/debian : https://backports.debian.org/Instructions/
then you will install nginx with the following command :
sudo apt-get install nginx -t jessie-backports
The rest of the band, you can install as per the tutorial or if you want you can use latest packages from backports too.
Here I installed PHP and MySQL to run Wordpress. Unfortunately Wordpress is MySQL centric so there is not much alternative (Maria DB, the open source alternative is still possible)
sudo apt-get install php5-fpm php5-curl php5-gd php5-cli php5-mcrypt php5-mysql php-apc mysql-server
same as the tutorial from https://www.pestmeester.nl/
same as the tutorial from https://www.pestmeester.nl/
//etc/php5/fpm/pool.d/www.conf
same as the tutorial from https://www.pestmeester.nl/
same as the tutorial from https://www.pestmeester.nl/ except that I use /web/ instead of /data/
I changed the home directory of www-data user to avoid confusion:
from
/var/www
to
/home/www-data
with the following command (you might have to stop processes ran by www-data to perform this operation)
$ sudo usermod --move-home --home /home/www-data www-data
use default website to confirm the basic nginx setup.
same as the tutorial from https://www.pestmeester.nl/
use default website to confirm the basic nginx/php setup.
same as the tutorial from https://www.pestmeester.nl/
In my case, I am using CloudFlare as my DNS Server/ & CDN. Configuration will be explained under cloudflare-config
And finally your router must be configured for NAT (ipV4) port forwarding.
Since I am using Let's Encrypt as my SSL Certifiate provider, I did not follow the documentation. Instead I have used one of the Let's encrypt client Certbot and configure my website to use the SSL Certificates.
To obtain/renew SSL Certificate, see documentation under letsencrypt-runbook
Once you have the SSL Certificate, modify your website configuration and add : ToDo
This part is quite big so documentation is split under nginx-wordpress-runbook