exit
.
Then type the command
ssh mprogrammer@yourdomain.comReplace the name
yourdomain.com
with the domain name that you purchased.sudo apt update sudo apt install g++ sudo apt install apache2
sudo ufw allow OpenSSH sudo ufw enableYou can try to access the website by browser. Type
yourdomain.com
in the URL field of the browser. Hopefully it will not work - and this is the sign that the firewall is working. We will need to open the firewall a little bit to allow web traffic.
Type the following command in the terminal
sudo ufw allow 'Apache Full'
yourdomain.com
. You should see the first page with title Apache2 Ubuntu Default Page.
sudo apt install certbot python3-certbot-apache
sudo certbot --apache
yourdomain.com
and www.yourdomain.com
and separate them with a space character. Press enter and wait for verification.
HTTPS
. Very likely this will be the choice 2.
When a user tries to access a non-existing page, the server will send 404 message. The default message contains too much information for non-friendly users and hackers. For example, they tell the user what version of apache is installed. We will now change the default message to omit that kind of data.
cd /var/www/html
myCustomError404.html
.
nano myCustomError404.html
<HTML> <HEAD> <meta HTTP-EQUIV="REFRESH" content="0; url=https://yourdomain.com"> </HEAD><BODY> <FONT SIZE=+2> Page Not Found </FONT> <BR> The requested page not found. You will be redirected to the homepage <a href="https://yourdomain.com">https://yourdomain.com</a> </BODY> </HTML>
ctrl+x
followed by yes
)./etc/apache2/sites-available/
. You may first list all files in the folder and identify the correct one. Most likely it is sudo nano /etc/apache2/sites-available/000-default-le-ssl.conf
.
sudo nano /etc/apache2/sites-available/000-default-le-ssl.conf
ServerName
. The text around that line looks something like:
ServerName yourdomain.com Include /etc/letsencrypt/options-ssl-apache.conf
ErrorDocument 404 /myCustomError404.html
immediately after the line that starts with ServerName
. The new text should look like this:
ServerName yourdomain.com ErrorDocument 404 /myCustomError404.html Include /etc/letsencrypt/options-ssl-apache.conf
sudo service apache2 restart