[201/lab sheet] Make all links visible just in case the hyperlinks don't work
continuous-integration/laminar-elessar Build 78 succeeded in 1 minute 19 seconds . Details

This commit is contained in:
Starbeamrainbowlabs 2019-10-28 14:00:42 +00:00
parent fff138a195
commit 54659461c7
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 46 additions and 21 deletions

View File

@ -21,8 +21,12 @@ It is worth mentioning before we begin though that this lab sheet will _not_ be
Despite this, links to some useful tutorials showing you how to do these things will be provided at the end of this lab sheet. In addition, you can always ask on the Freeside Discord or Forums, and we'll be happy to help you out:
- [Discord](http://discord.freeside.co.uk/)
- [Forums](https://forums.freeside.co.uk) - Login with your Freeside account (or get one [here](https://profiles.freeside.co.uk/login)!)
- [Discord](http://discord.freeside.co.uk/) [^discord_invite]
- [Forums](https://forums.freeside.co.uk) [^forums] - Login with your Freeside account (or get one [here](https://profiles.freeside.co.uk/join) [^freeside_account]!)
[^discord_invite]: <http://discord.freeside.co.uk/>
[^forums]: <https://forums.freeside.co.uk>
[^freeside_account]: <https://profiles.freeside.co.uk/join>
Finally, before we get started, a word on the rationale behind the software we're going to be using in this tutorial. Firstly, Ubuntu Server is the server version of the highly popular Ubuntu Linux distribution - which has _heaps_ of support out there should you run into difficulties in the future after this lab. It's well tested, and great for beginners.
@ -230,14 +234,16 @@ Where `{username}` is the username of the new user account you created earlier,
##### For Windows users
_If your **local machine** is a Windows computer, then this is the section for you. If your local machine is a **Linux** computer, then skip this section and move onto the one below entitled "For Windows users"._
This section will assume that you are using [PuTTY](https://putty.org/) to connect via SSH to your server. Content in this section is taken from [this DigitalOcean tutorial](https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/).
This section will assume that you are using [PuTTY](https://putty.org/) (<https://putty.org/>) to connect via SSH to your server. Content in this section is taken from [this DigitalOcean tutorial](https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/) [^putty_tutorial].
Start the PuTTYgen program through your Start Menu, or by launching the `puttygen.exe` portable executable. The key generation program looks similar to this:
![A screenshot of PuTTYgen.](images/puttygen.png)
_(Above: A screenshot of PuTTYgen. Taken from [this DigitalOcean tutorial](https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/).)_
_(Above: A screenshot of PuTTYgen. Taken from [this DigitalOcean tutorial](https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/) [^putty_tutorial].)_
[^putty_tutorial]: <https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/>
Set the key type to _ED25519_, and click the generate button.
@ -348,13 +354,18 @@ sudo ufw allow imap
## Installing a Web Server
With our server secured, we can now install our web server. In this tutorial, we'll be using _[Nginx](https://nginx.org)_. Nginx is very powerful and [much more efficient](https://www.nginx.com/blog/nginx-vs-apache-our-view/) than Apache. This is done with `apt`, Ubuntu's package manager:
With our server secured, we can now install our web server. In this tutorial, we'll be using _[Nginx](https://nginx.org)_. Nginx is very powerful and [much more efficient](https://www.nginx.com/blog/nginx-vs-apache-our-view/) [^nginx_vs_apache] than Apache. This is done with `apt`, Ubuntu's package manager:
[^nginx_vs_apache]: <https://www.nginx.com/blog/nginx-vs-apache-our-view/>
```bash
sudo apt install nginx
```
The `apt` package manager manages the software and libraries installed on a Linux computer. Other package managers exist too, which are used in other distributions of Linux (such as _Arch Linux_, _Alpine Linux_, and _Fedora_). The concept is broadly similar to a package manager you might use to manage the dependencies of a program you're writing, such as [NuGet](https://www.nuget.org/) (for .NET) and [NPM](https://www.npmjs.com/) (for Javascript).
The `apt` package manager manages the software and libraries installed on a Linux computer. Other package managers exist too, which are used in other distributions of Linux (such as _Arch Linux_, _Alpine Linux_, and _Fedora_). The concept is broadly similar to a package manager you might use to manage the dependencies of a program you're writing, such as [NuGet](https://www.nuget.org/) [^nuget] (for .NET) and [NPM](https://www.npmjs.com/) [^npm] (for Javascript).
[^nuget]: <https://www.nuget.org/>
[^npm]: <https://www.npmjs.org/>
Anyway, with Nginx installed, we should be able to test it out - just as soon as we allow it through our firewall:
@ -430,9 +441,13 @@ File | Purpose
--------------------------------|---------------------------------
`/etc/nginx/nginx.conf` | The main configuration file. Global settings are defined here.
`/etc/nginx/sites-available/` | The virtual host configuration files. Put website configuration files here.
`/etc/nginx/sites-enabled/` | The enabled virtual hosts. This directory contains [symbolic links](https://linuxhandbook.com/symbolic-link-linux/) to the `sites-enabled` directory.
`/etc/nginx/sites-enabled/` | The enabled virtual hosts. This directory contains [symbolic links](https://linuxhandbook.com/symbolic-link-linux/) [^symlinks] to the `sites-enabled` directory.
Nginx, like most web servers, can service multiple web servers at the same time. This is done by using a variety of techniques to determine what domain name you have entered into your address bar (namely the `Host` HTTP header and, in the case, of HTTPS, [Server Name Indication](https://en.wikipedia.org/wiki/Server_Name_Indication)). To this end, it supports multiple _virtual hosts_ - which are basically configuration files that tell it which website to serve under which circumstances.
[^symlinks]: https://linuxhandbook.com/symbolic-link-linux/
Nginx, like most web servers, can service multiple web servers at the same time. This is done by using a variety of techniques to determine what domain name you have entered into your address bar (namely the `Host` HTTP header and, in the case, of HTTPS, [Server Name Indication](https://en.wikipedia.org/wiki/Server_Name_Indication) [^sni]). To this end, it supports multiple _virtual hosts_ - which are basically configuration files that tell it which website to serve under which circumstances.
[^sni]: <https://en.wikipedia.org/wiki/Server_Name_Indication>
Try looking at some of the different configuration files in the `/etc/nginx` directory to get a feel for how it works - particularly `/etc/nginx/nginx.conf`.
@ -546,9 +561,11 @@ The `listen` directives tell Nginx to listen on Ipv4 and IPv6 for requests.
The `root /var/www/html;` directive tells Nginx where to find the files that it should serve. For our example, let's change this from `/var/www/html` to `/srv/www`.
The `location { }` blocks allow us to tell Nginx to do specific things for specific subdirectories. They are quite complex, and are out-of-scope of this workshop. However, the default configuration file contains some links that you can use to find out more - and you can always ask on the [Freeside Discord](http://discord.freeside.co.uk/) too.
The `location { }` blocks allow us to tell Nginx to do specific things for specific subdirectories. They are quite complex, and are out-of-scope of this workshop. However, the default configuration file contains some links that you can use to find out more - and you can always ask on the [Freeside Discord](http://discord.freeside.co.uk/) [^discord_invite] too.
You may wish to enable [directory listing](https://nginxlibrary.com/enable-directory-listing/), so that if Nginx does not find an `index.html` file it will list the contents of the directory instead. You can do this by creating a new line directly below the `root` directory like so:
You may wish to enable [directory listing](https://nginxlibrary.com/enable-directory-listing/) [^dir_listing], so that if Nginx does not find an `index.html` file it will list the contents of the directory instead. You can do this by creating a new line directly below the `root` directory like so:
[^dir_listing]: <https://nginxlibrary.com/enable-directory-listing/>
```nginx
autoindex on;
@ -595,24 +612,32 @@ sudo usermod -a -G www-data YOUR_USERNAME_HERE
This adds your user account to the `www-data` group. You will need to log out and log back in again at this stage for the change to take effect.
Actually uploading files can be done using SFTP. Windows users can use [WinSCP Portable](https://winscp.net/eng/docs/portable), while Linux users can use their native file manager (try entering `sftp://username@1.2.3.4/` into your address bar).
Actually uploading files can be done using SFTP. Windows users can use [WinSCP Portable](https://winscp.net/eng/docs/portable) [^winscp], while Linux users can use their native file manager (try entering `sftp://username@1.2.3.4/` into your address bar).
[^winscp]: <https://winscp.net/eng/docs/portable>
Once you have uploaded some files to your web server, try refreshing your web browser! You should see your new website appear before your eyes.
## Conclusion
We've looked at setting up a basic Linux web server with Ubuntu Server 18.04 and Nginx. We've done this by first taking some basic steps to secure our server, and then installing and configuring the necessary software.
This workshop should provide you with a good starting point from which to explore more complex uses for Linux. For example, you could now use your new web server to serve a [personal static website and blog](https://www.staticgen.com/), or you could take your skills further and learn about containerisation technologies such as [LXD](https://linuxcontainers.org/lxd/) and [Docker](https://www.docker.com/). You could even learn how to deploy your own application to a Linux server using a [system service](https://starbeamrainbowlabs.com/blog/article.php?article=posts/326-systemd-service-files.html) and [syslog](https://starbeamrainbowlabs.com/blog/article.php?article=posts/345-logrotate.html) - the possibilities are endless!
This workshop should provide you with a good starting point from which to explore more complex uses for Linux. For example, you could now use your new web server to serve a [personal static website and blog](https://www.staticgen.com/) [^staticgen], or you could take your skills further and learn about containerisation technologies such as [LXD](https://linuxcontainers.org/lxd/) [^lxd] and [Docker](https://www.docker.com/) [^docker]. You could even learn how to deploy your own application to a Linux server using a [system service](https://starbeamrainbowlabs.com/blog/article.php?article=posts/326-systemd-service-files.html) [^system_service] and [syslog](https://starbeamrainbowlabs.com/blog/article.php?article=posts/345-logrotate.html) [^logrotate] - the possibilities are endless!
Be sure to join the [Freeside Discord](http://discord.freeside.co.uk/), where you can learn more about Linux and hang out with other Linux users.
[^staticgen]: Static site generator comparison: <https://www.staticgen.com/>
[^lxd]: <https://linuxcontainers.org/lxd/>
[^docker]: <https://www.docker.com/>
[^system_service]: <https://starbeamrainbowlabs.com/blog/article.php?article=posts/326-systemd-service-files.html>
[^logrotate]: <https://starbeamrainbowlabs.com/blog/article.php?article=posts/345-logrotate.html>
Be sure to join the [Freeside Discord](http://discord.freeside.co.uk/) [^discord_invite], where you can learn more about Linux and hang out with other Linux users.
## References and Further Reading
- [Linux command reference](https://files.fosswire.com/2007/08/fwunixref.pdf)
- [Learn your terminal (or command line)](https://starbeamrainbowlabs.com/blog/article.php?article=posts/242-Learn-Your-Terminal.html)
- [Nginx](https://www.nginx.com/)
- [How to Secure a Linux Server](https://github.com/imthenachoman/How-To-Secure-A-Linux-Server/)
- [SSL Certificates](https://letsencrypt.org)
- [How to secure Nginx with Let's Encrypt on Ubuntu Server 18.04](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04)
- [Freeside Discord Invite](http://discord.freeside.co.uk/)
- [Static Site Generators Comparison](https://www.staticgen.com/)
- [Linux command reference](https://files.fosswire.com/2007/08/fwunixref.pdf) (<https://files.fosswire.com/2007/08/fwunixref.pdf>)
- [Learn your terminal (or command line)](https://starbeamrainbowlabs.com/blog/article.php?article=posts/242-Learn-Your-Terminal.html) (<https://starbeamrainbowlabs.com/blog/article.php?article=posts/242-Learn-Your-Terminal.html>)
- [Nginx](https://www.nginx.com/) (<https://www.nginx.com/>)
- [How to Secure a Linux Server](https://github.com/imthenachoman/How-To-Secure-A-Linux-Server/) (<https://github.com/imthenachoman/How-To-Secure-A-Linux-Server/>)
- [SSL Certificates](https://letsencrypt.org) (<https://letsencrypt.org>)
- [How to secure Nginx with Let's Encrypt on Ubuntu Server 18.04](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04) (<https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04>)
- [Freeside Discord Invite](http://discord.freeside.co.uk/) (<http://discord.freeside.co.uk/>)
- [Static Site Generators Comparison](https://www.staticgen.com/) (<https://www.staticgen.com/>)