0

I'm replicating an Apache installation to a new server in a different data centre.

I installed the same version of Apache on the new server and would like to copy all the relevant files from the old server.

Does the following include all the relevant Apache files, or did I miss some files/directories?

#!/bin/bash

HOSTNAME=$( hostname )
ARCHIVE="/tmp/httpd_on_${HOSTNAME}.tar"
rm $ARCHIVE
tar cf $ARCHIVE --exclude="ssl*log*" /run/httpd /sys/fs/cgroup/devices/system.slice/httpd.service /sys/fs/cgroup/systemd/system.slice/httpd.service /etc/logrotate.d/httpd /etc/systemd/system/multi-user.target.wants/httpd.service /etc/systemd/system/httpd.service.d /etc/sysconfig/httpd /etc/httpd /etc/httpd/conf/httpd.conf /var/tmp/systemd-private-*-httpd.service-* /var/log/httpd /var/cache/httpd /var/www

Note: Apache version is 2.4.6 (on CentOS 7.6)

boardrider
  • 949
  • 2
  • 18
  • 29

1 Answers1

0

FIRST !, read about Apache config. There is plenty of docs out there to help you. Even examples that will help you understand your setup

You will also want to modify your config files at destination as your new server IP will not be the same (1 example).

Drop this: /run/https/ /sys/fs/cgroup/devices/system.slice/httpd.service /sys/fs/cgroup/systemd/system.slice/httpd.service /etc/systemd/system/multi-user.target.wants/httpd.service /etc/systemd/system/httpd.service.d /etc/sysconfig/httpd /var/tmp/systemd-private--httpd.service- /var/log/httpd /var/cache/httpd /var/www

Keep this: /var/www <<--- this is the web site data (mostly, unless you only are a proxy)

/etc/httpd (all of it and under, as this is you Apache config)

May be keep this: /etc/logrotate.d/httpd (if modification are present, otherwise, destination will already have that)

/var/log/httpd (If you want to keep previous Apache logs)

Also... NEVER EVER do a ''rm $variable'' more specificaly ''rm -rf'' as if the variable end up empty, this will do ''rm -rf /''.... That is your entire machine !

Sorry for all the !!

yield
  • 771
  • 1
  • 9
  • 24