I've used various Linux distributions throughout the years, but I've never used anything except Ubuntu for my servers. Why? I really have no idea - mostly just comfort around the commands and software availability.
However, I have always wanted to try Debian as a server OS after testing it out in a VM a few years ago (side-note: I'd love to try Alpine too, but I always struggle with compatibility). So, I decided to launch a new VPS and use Debian 11 as the OS. Spoiler alert: it feels identical to Ubuntu for my purposes.
I did the normal things when first launching the VPS, such as adding a new user, locking down SSH, etc. If you want to see that level of detail, read my other post about How to Set Up a VPS Web Server.
All of this has been similar, apart from small things such as the location of users' home folders. No complaints at all from me - Debian seems great.
Once I had the baseline server configuration set-up for Debian, I moved on to
trying out Nginx as my web server software. This required
me to install the nginx
and ufw
packages, as well as setting up the initial
UFW config:
Once I had the firewall set, I moved on to creating the directories and files for my website. This is very easy and is basically the same as setting up an Apache server, so no struggles here.
The next part, creating the Nginx configuration files, is quite a bit different
from Apache. First, you need to create the files in the sites-available
folder
and symlink it the sites-enabled
folder.
Creating the config file for your domain:
Default content for an Nginx config file:
Finally, symlink it together:
This will make your site available to the public (as long as you have
your_domain
DNS records pointed at the server's IP address)!
Next, I used certbot to issue an HTTPS certificate for my domains using the following commands:
; ;
Now that certbot ran successfully and updated my Nginx config files to include a
443
server block of code, I went back in and edited the config file to include
security HTTP headers. This part is optional, but is recommended for security
purposes - you can even test a website's HTTP header security at
Security Headers.
The configuration below shows a set-up where you only want your website to serve
content from its own domain - except for images and scripts, which may come from
nullitics.com
. All other content would be blocked from loading in a browser.
As I stated at the beginning, my historical hesitation with trying Nginx was that the differences in configuration formats scared me away from leaving Apache. However, I actually prefer Nginx over Apache for a few reasons:
your_domain
) vs. Apache's two-file
approach for HTTP vs. HTTPS (your_domain.conf
and
your_domain-le-ssl.conf
).a2enmod mod_headers
,
enable PHP with a2enmod php
(plus any other mods you need), and then
enabling sites with a2ensite
, and THEN reloading Apache.They're both great software packages, but Nginx just seems more organized and easier to use these days (in my situation - everyone is different). I will certainly be exploring the Nginx docs to see what other fun things I can do with all of this.
Finally, I set up the Agate software on this server again to host my Gemini server content - using Rust as I have before. You can read my other post for more information on installing Agate: Hosting a Gemini Server.
All in all, Debian + Nginx is very slick and I prefer it over my old combination of Ubuntu + Apache (although it's really just Nginx > Apache for me, since Debian seems mostly the same as Ubuntu so far).