Change Default IP Address for Name-based Sites

When you’re hosting multiple websites on the same server using name-based virtual hosting, your server needs to map each site to an IP address. By default, Apache assigns the first IP available, but sometimes you may want to change the default IP address for name-based sites, maybe due to SSL requirements, DNS changes, or server configuration updates.

What Are Name-Based Sites?

Name-based hosting allows multiple websites to share a single IP address. The web server uses the domain name in the HTTP request to decide which site to serve.

  • Saves IP addresses when hosting many domains.

  • Useful for shared hosting environments.

  • Easy to manage multiple websites from one server.

Steps to Change Default IP Address for Name-Based Sites

This guide explains the step-by-step process to update the default IP address for name-based sites on your server.

1. Edit the Virtual Hosting Configuration

Open the name-based IP address configuration file:

nano /etc/virtualhosting/namebased_ip_addrs

Update the IP address to your desired new IP.

2. Update the Hosts File

Edit the “/etc/hosts” file and add or update the entries for your domains with the new IP address.

3. Modify Apache Configuration

Open the Apache configuration file:

“nano /etc/httpd/conf/httpd.conf”

Search for NameVirtualHost and update the IP accordingly.

4. Update Application Config File

If you are using a CMS like WordPress with phpMyAdmin, update the configuration file:

“nano /var/www/html/MyAdmin/wp.config.inc.php”

5. Update IP Detection File

Edit the file that detects IP changes:

“nano /etc/detectchanges/IP”

6. Run NBDetectChanges

After making changes, run the following command to detect and apply updates:

“/usr/local/bin/NBDetectchanges”

7. Resave All Sites

Finally, resave all the name-based sites to ensure changes are applied.

 

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

What is CPM (Cost per impression) / CPC (Cost per Click) / CPT (Cost per Time)?

In online advertising, CPM is in relation to traffic that is eventually received on the…

Want to Migrate Your Website from Cloud to cPanel Hosting?

Cloud and cPanel web hosting both are the best but there are differences in their…

How to Install Python on Debian 12

Python is a powerful programming language known for its simplicity and readability. It is used…