DeveloperBreeze

Objective

We’ll rename an existing subdomain from old.example.com to new.example.com, update Apache configuration files, and generate a new SSL certificate using Certbot.


1. Rename and Update Configuration Files

First, rename your Apache configuration files to reflect the new subdomain name.

  1. Rename the Config Files: Use the mv command to rename the Apache config files for the new subdomain:
   sudo mv /etc/apache2/sites-available/old.example.com.conf /etc/apache2/sites-available/new.example.com.conf
   sudo mv /etc/apache2/sites-available/old.example.com-le-ssl.conf /etc/apache2/sites-available/new.example.com-le-ssl.conf
  1. Edit Configuration Files: Open each of the renamed files and replace any instance of old.example.com with new.example.com.
   sudo nano /etc/apache2/sites-available/new.example.com.conf

Make the necessary changes, save, and close the file. Repeat this step for the new.example.com-le-ssl.conf file as well.


2. Disable the Old Site and Enable the New One

Disable the old site and enable the newly configured site:

sudo a2dissite old.example.com.conf
sudo a2ensite new.example.com.conf

After enabling the new configuration, reload Apache for the changes to take effect:

sudo systemctl reload apache2

3. Generate a New SSL Certificate

Since the SSL certificate is tied to the specific domain name, you’ll need to create a new one for new.example.com. Certbot makes this easy.

Run the following command:

sudo certbot --apache -d new.example.com

This command will:

  • Generate a new SSL certificate for new.example.com.
  • Automatically update the new.example.com-le-ssl.conf file with the correct paths to the new SSL certificate.

4. Clean Up the Old SSL Certificate (Optional)

To keep things organized, you can remove the old SSL certificate for old.example.com if it’s no longer needed.

Use Certbot’s delete command:

sudo certbot delete --cert-name old.example.com

This will remove the certificate files associated with old.example.com.


5. Verify Everything is Working

After setting up the new configuration and SSL certificate, verify that Apache is running correctly:

  1. Check Apache Status:
   sudo systemctl status apache2
  1. Test Access in Browser:

Open your browser and visit https://new.example.com to ensure that it’s accessible with a valid SSL certificate.


By following these steps, you’ll successfully rename a subdomain from old.example.com to new.example.com and set up a fresh SSL certificate. This ensures your updated domain is secure and properly configured.

Continue Reading

Discover more amazing content handpicked just for you

Tutorial
bash

How to Install and Configure Apache on Ubuntu

sudo ufw app list

You should see an output similar to:

Oct 21, 2024
Read More
Tutorial
bash

How to Create SSL for a Website on Ubuntu

sudo nano /etc/nginx/sites-available/default

Add the following lines under your server block to enhance security:

Oct 21, 2024
Read More
Tutorial

Adding a Subdomain on an Apache Server

   sudo nano /etc/apache2/sites-available/blog.example.com.conf
   <VirtualHost *:80>
       ServerAdmin admin@example.com
       ServerName blog.example.com
       DocumentRoot /var/www/blog.example.com

       <Directory /var/www/blog.example.com>
           Options Indexes FollowSymLinks
           AllowOverride All
           Require all granted
       </Directory>

       ErrorLog ${APACHE_LOG_DIR}/blog.example.com-error.log
       CustomLog ${APACHE_LOG_DIR}/blog.example.com-access.log combined
   </VirtualHost>

Aug 21, 2024
Read More
Tutorial
python bash

Deploying a Flask Application on a VPS Using Gunicorn and Nginx

git clone https://github.com/username/your-flask-app.git
cd your-flask-app

Replace https://github.com/username/your-flask-app.git with the URL of your repository.

Aug 03, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!