Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Apache 2 server set up on my computer that I use for local testing. To be clear, it is not hosting sites on the internet. It's just for local debugging and designing.

I was using Ubuntu Linux, but now I have a new computer using Linux Mint. What I'd like to do is take all the Apache sites and settings that I have on the old Ubuntu machine and reproduce them on the new Linux Mint machine.

I only know how to do this manually, one site at a time, starting from scratch. Creating a file for each site in the sites-available directory and activating them with a2ensite. And then making edits to any configuration files, like adding some lines to my php.ini file to enable Xdebug, and hoping I haven't missed anything.

I'm sure I'm doing this inefficiently and in a way that's prone to human error.

Is it not possible to in some way copy the entirety of the Apache 2 settings and sites on my Ubuntu machine and put them on my Linux Mint machine in one go? Or at least, in a minimum of steps that is less than recreating each site and setting from scratch?

Please note that I am more of a designer than an administrator, so please assume my knowledge of Linux commands and server settings is minimal.

share|improve this question
Why don't you just copy all the files from sites-available from your old install to the new install, den go to sites-enabled and create a symlink for each available site you want enabled? – Bananguin May 3 '13 at 8:21
up vote 3 down vote accepted

Your server settings, like any system-wide program settings, are to be found under /etc. The exact location depends on the distribution, but /etc/apache or /etc/apache2 are good bets. Both Ubuntu and Mint use /etc/apache2.

If you have the same plug-ins installed and versions of Apache that aren't too far apart, you can simply copy the whole /etc/apache2 directory to the new machine. You'll need to copy your document root(s) as well, of course.

If you're running some web applications, you'll need to migrate them as well. This may or may not be as straightforward as copying some files, it depends heavily on the application. In particular, if there's a database involved, you'll need to install the same database software (typically MySQL), dump the database on the old machine, and restore the dump on the new machine.

share|improve this answer
Thank you for responding. 2 follow up questions: Do I not also need to copy the etc/hosts file or any other system files? Also, when you say "web applications", would that include something like PHP? I use PHP in all my sites, but I'm not sure if the relevant configuration files are in the /etc/apache2 directory, or in their own directory somewhere. – Questioner May 4 '13 at 3:39
@DaveMG For PHP itself, you only need to ensure that it's installed. For the applications written in PHP, you may need to copy the applications' data. If you've added aliases for localhost in /etc/hosts, then yes, you need to copy those. – Gilles May 4 '13 at 10:10

Is it not possible to in some way copy the entirety of the Apache 2 settings and sites on my Ubuntu machine and put them on my Linux Mint machine in one go?

Presuming they are not vastly different Apache versions, yes. Distros pre-configure apache with minor differences (eg, the web root location) but if you are copying in your configuration and put everything in the same place, just do it wholesale. As in overwrite the configuration, don't twiddle with editing it the same way. Be aware that the location of apache's conf files is compiled into the apache binary, and may differ from distro to distro. What's in the conf files, however, is portable, so you should be able to just replace the files with your own. Besides the location of the conf file, apache's behaviour is determined by what's in the conf file(s), so if you do replace it/them, then, eg., the web root will be determined by your "new" configuration. Another detail here, as you've caught onto, is the stuff in /etc/hosts.

Apache sometimes uses semi-independent parts (eg. php) that have their own configuration. If you know you are using something like that you have to do a bit of homework to find out the details.

This begs the question of how you keep the server backed up; if you do that coherently, it is just a matter of deploying the backup on another machine (ie., as if it had been totally fubarred). By "server backup" I do not mean your entire filesystem, or the apache binary, which is already effectively backed up because it is a distro package. I mean everything in the web root (eg. /var/www) -- all the data files, scripts, etc. that the server uses -- and the configuration, which is probably somewhere in /etc; as mentioned this location is variable but compiled into apache, meaning if you want to deploy on a different distro, you may have to put the conf file(s) in a different place.

How exactly you do that depends on the nature of your server. If you are serving various things that are in themselves stand-alone projects, those projects should be backed up independently; this should include some documentation about how they should be deployed and what they require, possibly including snippets of apache config if appropriate. This means the project can be easily installed into any apache. If the server is dedicated to one thing, you can just back-up the entire web root. In the former case (various independent projects), using some form of VCS is good (these are good things to learn to use; my personal preference is git but there are plenty of others), in the latter (one megalithic web root) something like rsync -- but those are just suggestions. The point is you should have a tool you are comfortable with for stuff like this (selectively backing up directory sub-trees in a filesystem). The simplest way on a small installation is probably just tar (or zip).

If you are using a backend database with apache, you want to back that up along the same lines too -- the data and the configuration, but if the database is used by various different projects that are independently backed up, their data should be backed up with them.

So, if you maintain a backup of this sort, all you have to do to "duplicate your apache" is install apache, then deploy the backup -- you untar, rsync, git clone, whatever, the various parts, copy the configuration into the right place, and presto.

You may then have an issue with missing software -- distros may bundle the apache modules differently, you need sql, etc -- but that is pretty straightforward.

share|improve this answer
Thank you for responding. Just as a note, I keep a backup of my whole partition, so if things go totally fubar, I have a recovery. However, in this instance I'm trying to use the transfer to a new computer to start fresh and solve some other problems. For example, my last computer was having problems playing flash video, but my new one isn't. So I'm selectively copying over the functionality that works. My Apache settings and sites is one of the things I'd like to keep as it was. – Questioner May 4 '13 at 3:33
@DaveMG : Actually what I meant by "server backup" was just the apache installation (by which I don't mean the package binaries), although I guess if you had that separately to start with, you wouldn't have asked the question...I'll add some stuff to that paragraph to clarify. – goldilocks May 4 '13 at 10:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.