I need to update the domain name for my website hosted through Digital Ocean.
I have the A records pointed to the new domain and the website displays, however when I run certbot, it only gives me the option for the old domain to generate a certificate.
My old domain is new.example.com and my new one is just example.com.
Please advise what I need to do to fix this and update the domain.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @harrywilson100,
First, you need to update your Apache configuration file and change the domain from example.com to new.example.com.
Usually, you can find the apache configuration file in the /etc/apache2/sites-enabled/ folder. In those files you need to change the following lines;
ServerName example.com
ServerAlias www.example.com
Once you do, don’t forget to restart Apache. After those change certbot should be able to find the proper domain when it’s being called.
The next thing would be to update the database of your website. What I mean is, your database will contain references to the old domain. You’ll need to update it with the new one.
Hello, @harrywilson100
Are you hosting the site on a plain Ubuntu droplet or you have a control panel like cPanel/WHM installed as well? The process may vary with the different configuration.
If you simply have a LAMP/LEMP stack droplet you will need to update your virtual hosts and also rename the file for the domain name as well. The location of the vhosts on Ubuntu droplet is the following: /etc/apache2/sites-available and a symlink in the /etc/apache2/sites-enabled directory as well.
You can open the configuration file of the domain name and then change the lines that KFSys already mentioned:
ServerName
ServerAlias
Also to rename the file you can just use mv :
mv yourdoman.com.conf newdomain.com.conf
Then you can check the Apache configuration for any syntax errors using this command:
sudo apachectl -t
If you get Syntax OK you can go ahead and restart Apache with this command:
service apache2 restart
If you’re using Nginx the location of the configuration files is /etc/nginx/sites-available/ and the line you need to change in the file is the server_name and then you can again rename the file to match the new domain name.
Test your the configuration file for syntax errors by typing:
sudo nginx -t
You will also need to change the domain name in the WordPress installation as well. You can check this question that was previously asked in our community in order to do that:
https://www.digitalocean.com/community/questions/change-url-in-wordpress?answer=59927
Hope that this helps! Regards, Alex
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.