Создать субдомен | Nginx | Рыбная раковина

set subdomain "apps.example.com"
# Create directory
sudo mkdir /var/www/$subdomain
# Create index.html
sudo vim /var/www/$subdomain/index.html

# 1. Copy the default config for the new subdomaine
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/$subdomain
sudo ln -s /etc/nginx/sites-available/$subdomain /etc/nginx/sites-enabled/$subdomain
  
# 2. Open the config file
sudo echo "<h1>Subdomain Works!</h1>" > /etc/nginx/sites-available/$subdomain
  
# 3. Edit the file
# The content should look something like this
server {
        listen 80;
        listen [::]:80;
        root /var/www/apps;
        index index.html;
        server_name apps.example.com;
}
  
# 4. Restart NGINX
sudo service nginx restart

# Obtain an SSL Certificate
sudo certbot --nginx -d $subdomain
Just-Moh-it