How to Rename an Apache Website Virtual Host on Ubuntu

I recently setup a Linode Linux server and am getting used to managing my sites without the help of cPanel. Depending on the circumstances, I sometimes setup a fake domain name on the new server and point the host file on my development computer to the fake domain name. This lets me run the live website and the development website side-by-side. This makes porting over existing content easier. Once the new website is ready to go live, I’ll rename the domain on the server to it’s actual value, remove the host file entries on my computer, then update public DNS.

Here’s how the renaming part is done on Ubuntu.

Disclaimer: I’m new to this! This worked great for me, but if there’s a better way, please let me know in the comments.

Renaming an Apache virtual host on Ubuntu 14.04

Example: we will be renaming example2.com to example.com

  1. Rename the directory holding the site
  2. Rename the virtual host conf file
  3. Open the example.com.conf file and update the domain name from example2.com to example.com
  4. Enable the “new” site
  5. Remove the “old” site symlink
  6. Restart the Apache service

Done!

3 thoughts on “How to Rename an Apache Website Virtual Host on Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *