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
- Rename the directory holding the site
1sudo mv /var/www/example2.com /var/www/example.com - Rename the virtual host conf file
1sudo mv /etc/apache2/sites-available/example2.com.conf /etc/apache2/sites-available/example.com.conf - Open the example.com.conf file and update the domain name from example2.com to example.com
1sudo nano /etc/apache2/sites-available/example.com.conf - Enable the “new” site
1sudo a2ensite example.com.conf - Remove the “old” site symlink
1sudo a2dissite example2.com.conf - Restart the Apache service
1sudo service apache2 restart
Done!
Did you forget the “.conf” part in step 2?
Yes, I did! Thanks. It’s fixed now.
You also have to
a2disconf oldsite
and rename the file under conf-avaliable and thena2enconf newsite
and reload service.