Server

Domain Management on your Strato Server

In this tutorial, we'll explain how to add a new website to your Strato server, configure it in Apache, and set up HTTPS with Certbot. This guide assumes you have a working server with Apache and Certbot installed.

Contents

  1. Add a new website in Apache
  2. Activate and manage a website
  3. Configure HTTPS with Certbot
  4. Manage website permissions
  5. Important status commands

Add a new website in Apache

  1. Create a new configuration for your website:
sudo nano /etc/apache2/sites-available/websitedomain.conf
  1. Add the following configuration (replace websitedomain with your own domain name):
<VirtualHost *:80>
ServerAdmin webmaster@websitedomain 
ServerName website domain 
ServerAlias ​​www.websitedomain 

DocumentRoot /var/www/websitedomain/public 

<Directory /var/www/websitedomain/public> 
Options Indexes FollowSymLinks 
AllowOverrideAll 
Require all granted 
</Directory> 

ErrorLog ${APACHE_LOG_DIR}/websitedomain_error.log 
CustomLog ${APACHE_LOG_DIR}/websitedomain_access.log combined 
</VirtualHost>
  1. Save the file and close the editor.

Activate and manage your website

  1. Activate the new site in Apache:
sudo a2ensite websitedomain.conf
  1. Reload Apache to apply the changes:
sudo systemctl reload apache2
  1. To temporarily disable a website:
sudo a2dissite websitedomain.conf
sudo systemctl reload apache2
  1. View Apache's status:
sudo systemctl status apache2

Set up HTTPS with Certbot

If Certbot and the Certbot Apache plugin are already installed, you can easily enable HTTPS:

  1. Run Certbot for your domain:
sudo certbot --apache -d websitedomain -d www.websitedomain
  1. Follow the on-screen instructions, for example:
  • Enter your email address for important notifications
  • Accept the terms of use
  • Choose whether to automatically redirect HTTP traffic to HTTPS

Install Certbot (if not already installed)

If Certbot is not already installed, you can add it as follows:

sudo apt update
sudo apt install certbot python3-certbot-apache

Manage website permissions

Ensure that Apache has access to the correct directories, especially for Laravel projects:

sudo chown -R www-data:www-data /var/www/websitedomain/storage
sudo chown -R www-data:www-data /var/www/websitedomain/bootstrap/cache
sudo chmod -R 775 /var/www/websitedomain/storage
sudo chmod -R 775 /var/www/websitedomain/bootstrap/cache

Important status commands

  • Check Apache status:
sudo systemctl status apache2
  • View Certbot certificates:
sudo certbot certificates
  • Check firewall status (optional):
sudo ufw status

Tips

  • Make sure your DNS records correctly point to your server IP.
  • After adding a new site, always test your configuration with:
sudo apache2ctl configtest
  • If in doubt, restart Apache:
sudo systemctl restart apache2

Your website should now be fully online and secure via HTTPS. For further management information, you can always consult the Apache and Certbot documentation.


Useful Commands

Below is a list of frequently used commands to quickly manage your websites and Apache configurations:

  • View all websites:
sudo apachectl -S
  • Open the Apache configuration for a specific site:
sudo nano /etc/apache2/sites-available/websitedomain.conf
  • View the HTTPS configuration for a site:
sudo nano /etc/apache2/sites-available/websitedomain-le-ssl.conf
  • View all available websites (sites-available):
ls -l /etc/apache2/sites-available/
  • View all enabled websites (sites-enabled):
ls -l /etc/apache2/sites-enabled/
  • Test Apache configuration for errors:
sudo apache2ctl configtest
  • Restart Apache (required after configuration changes):
sudo systemctl restart apache2
  • Reload Apache (for minor changes):
sudo systemctl reload apache2
  • Check Apache status:
sudo systemctl status apache2
  • Show certbot certificates:
sudo certbot certificates
  • View firewall status:
sudo ufw status
  • Add firewall ports For HTTP and HTTPS (if necessary):
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
  • View logs for a specific website:
tail -f /var/log/apache2/websitedomain_access.log
tail -f /var/log/apache2/websitedomain_error.log

With these commands, you can quickly and effectively manage your websites and Apache configurations.

Good luck with your website management!