How to migrate your Apache-based web server running LAMP or ISPConfig if the server's IP address changes

botond published 2020. 08. 11., K - 22: 35 time



Sometimes it happens to be new for some reason IP addresses so you also need to modify the appropriate configuration files on your web server and make settings to keep the services running on the server running. Whether it is a home test environment, a live web server, or moving the server to another (network) environment, we need to make these settings in each case. In this description, we go through the changes inside or outside the server that we need to make in order for the services on the machine to work with the new IP address.

In my case, all that happened was that my old DIGI 100 net was replaced with the fiberglass 1000 package. This meant I also got a new router. Everything would have been nice and good, just that my old TP-Link router couldn't handle the gigabit pace, but could only produce speeds below 100 Mbps. So I had to transfer the computers to the new router. That wouldn't have been a problem with the new router DHCPwould have distributed IP addresses in the same address range as the old one (192.168.1.x). But unfortunately it didn't happen that way, instead of the address set on the old router - and used for many years - I was now able to choose an address from the 192.168.100.x domain, so my home server got the address. Unfortunately, in the new router (of this type) it is not possible to change the DHCP pool domain. I even asked customer service, unfortunately I have to use this address range. So there was nothing to do, everything had to be reconfigured on the server to keep working.

In this description, starting from my own example, I use these IP addresses (switching from to to show the changes in my home country. ISPConfigIn my server environment, but of course you can make these settings with any other - even public fixed - IP addresses.

Router setup (optional)

If it is a home test or development server and you get internet access from a router, in this case you need to set the internal fixed IP address here first. However, if it is a live server that gets a public fixed IP address and / or the net does not come through a router, skip this section.

For example, in my DIGI router, I assigned the IP address to the machine's MAC address to make sure that the computer always gets this:

Set a fixed internal IP address in the router

I intended this as an illustration only. As many routers, so many kinds of settings. So let’s improvise on setting up our own device.

Make settings on the server

Once the server has received a new IP address from the outside, follow these steps to use it.

Fixed fixed IP address

If your server (also) is set to a fixed IP address immediately after installation, such as for minimal servers also, you can properly repair the / etc / network / interfaces file as root:

sudo nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug enp0s3
#iface enp0s3 inet dhcp
auto enp0s3 
iface enp0s3 inet static

I also put this here for illustration only. Here we modify this file according to our own IP address. In this example, address, network, Broadcast and Gateway in the fields I only had to change the third parts of the IP addresses from 1 to 100, which I also highlighted, so here we set our new IP address in our own file accordingly.

If this file does not look like this and does not contain these fixed IP address settings, you will most likely get the IP address by DHCP address assignment, say from your router in which you have previously set your fixed IP address. In this case, we can skip this section because our router already provides a fixed IP address on our internal network by default.

Fix DNS setup (Optional)

Here, too, there are two variations: If you installed your server on a home network, the installer automatically set the DNS to the gateway address of your router. So if the situation is similar to mine and we have a new router - which has changed our IP address - then change the DNS setting to the gateway IP address of our new device. To do this, edit the / Etc / resolv.conf file:

sudo nano /etc/resolv.conf

Then set the appropriate gateway address in this. For example, I have:


However, if it's a live server, you can set up a free DNS service address, such as Google DNS:


This can even be used on a home network.

Hosts file settings adjustment (optional)

Although it is not mandatory to set anything in the hosts file, it is useful to use it in such situations, because this is the only way to change the IP addresses here, while in other places, e.g. in saved bookmarks or configuration files of browsers, etc., you only need to enter the hostnames you set in the hosts file. For example, I also set up a separate hostname to access ISPConfig, which makes it more convenient to access it. Or just that virtual machines created for I also set up your achievements here to make them easier to manage, so I had to fix them too.

So if you have previously set up hostnames associated with the old IP address in the hosts file, be sure to change them to the new address as well:

sudo nano /etc/hosts

If we haven’t set anything up here before, we don’t have anything to do with it.

Web server setup

After performing the basic settings, our websites still do not work. If we try to load them, we get the "ERR_SSL_PROTOCOL_ERROR" error when using SSL:

ERR_SSL_PROTOCOL_ERROR error due to incorrect IP address

LAMP server setup

Because the server has been assigned a new IP address, web pages hosted on it will not start. Especially if SSLWe also use web pages to make them HTTPSoperate through. This is because the Virtual hosting even the files contain the old IP addresses, so SSL does not work properly and the browser disables the page from loading for security reasons and throws an error. You can also search for these old addresses from the terminal with the following command:

grep -rnw "" /etc/apache2

LAMP in the case of a server, we can overwrite them (or even replace them with a single sed command) in the in our virtualhost files, finally one Apache after rebooting, the pages are already going.

Configuring ISPConfig

However, if you are using ISPConfig, do not access these files manually, as the control panel will overwrite the contents of your database when you save the next settings, so your manual settings will be lost. Instead, we need to get ISPConfig to fix these files for us.

Due to the change of the IP address, we cannot access the ISPConfig interface either, as it gives the same error as when accessing the web pages. Therefore, we need to fix the Apache configuration of the control panel first:

sudo nano /etc/apache2/sites-available/ispconfig.conf

And let's look for it in our old IP address and then fix it again:

Modify the ispconfig.conf file

The last two lines of the configuration contain the addresses to be repaired.

Then restart Apache:

sudo systemctl restart apache2

You can now access ISPConfig.

Change server IP address

Go to the "System" main menu and select the "Server IP" submenu here:

ISPConfig - Server IP address

Here you can see the item containing our server and the old IP address next to it. Edit the item by clicking on the hostname:

ISPConfig - Server IP address change

And set the new IP address like the picture and save it.

ISPConfig - Server IP address changed

Then wait for the red hoop at the top of the screen to disappear, then perform the required action in the background.

Setting up websites

As I wrote above, in a system managed by ISPConfig, you should not manually access virtualhost files. Instead, you need to modify the web pages in ISPConfig and then the control panel saves the page again with the appropriate virtualhost settings.

To do this, go to the "Sites" main menu. Then here we open our managed websites and edit everything by item. When entering the edit, the IP address has disappeared in the settings under the "Domain" tab ("*" will be displayed instead), because what was used to store the web page has already been corrected above:

ISPConfig - Websites - change website

Here, scroll down to the newly configured IP address, and then save the webpage.

ISPConfig - Websites - Change website - Select IP address

Wait until the red circle above disappears again. Then let’s open our websites, which then work.

The set up, working website.

Depending on your website, you may want to check your source and configuration files to see if the old IP address is listed somewhere, as it may be referenced somewhere by a file. For example, it can occur with older websites. When you are done with one page, repeat the IP address setting with the others.

Configure other machines on the network (optional)

If the server is on a home network and there are other computers on the network that use the server shares as a network drive or manage the server over saved SSH connections, you may want to set up the hosts files on the other machines to make the shares work again, other achievements, etc.


So that would be to change the IP address on an ISPConfigos Apache server. It’s not a complicated thing, but at first one may suddenly not know where to reach, so we need to look a little for the solution. So I hope with this little description I can save this search for those who change IP addresses on their server.