Server migration: apache virtual host

What is the best and fastest way to replicate apache virtual hosts to a new server?

When I need to change server I recreate all domains one by one with a procedure similar to this one:

sudo mkdir -p /var/www/html/sito.com
sudo chown -R $USER:$USER /var/www/html/sito.com
sudo chmod -R 755 /var/www/html/sito.com
sudo nano /etc/apache2/sites-available/sito.com.conf
------
<VirtualHost *:80> ServerAdmin ServerName sito.com ServerAlias DocumentRoot /var/www/html/sito.com <Directory /var/www/html/sito.com> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all # New directive needed in Apache 2.4.3: Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
-------
sudo a2ensite sito.com.conf
sudo systemctl reload apache2

and with 50, 100 domains this procedure is slow and tedious ...

Is there a fast and secure way to replicate the virtual hosts of the old server to a new server? Can there be problems with permissions and file owners?

I have ssh access and server root, ubuntu 20.04 server, apache, php8.1

3 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like