0

I have a bunch of web sites that I develop, and I run an Apache server locally to do debugging and design. The web sites use Apache, PHP, and MySQL. To be clear, my Apache server is not serving these sites to the internet, I just access them locally.

I develop on two machines. One desktop, and one laptop. Both are running Linux Mint, and I try to keep the settings consistent between them. This means I have to duplicate the Apache and PHP configurations. I keep the directory structures the same. I have to make sure to copy the MySQL databases from one machine to the other if I make changes.

Which is not ideal. It's prone to human error, especially with keeping the MySQL databases synched. Sometimes I work on one on one machine, forget to export and import the databases, and then after I've done work on the other machine, I have two versions and I can't easily merge them. Also, it's a hassle for making backups.

What does work is that I store all my HTML, CSS, and Javascript in a folder in my Dropbox directory. So any changes I make to those files are automatically syncronized. It also means I have a backup in the cloud. Should the need arise, to restore these files if I ever move to a new machine, I just have to install Dropbox and all the files are recovered.

The most I have to do if setting up on a new computer is create a symlink to my Dropbox directory where my HTML files are stored:

sudo ln -s  /home/dave/Dropbox/Websites /var/www/Websites

Is there a way I can do this with my Apache settings and MySQL databases as well? Where I can keep them synchronized across both machines in my Dropbox folder, and have a miminum of set up if I go to a new machine?

1

For apache you can easily put the sites-available in dropbox and then symlink the sites you want to enable to to the sites-enabled folder in /etc/apache2/sites-enabled/[name]

as for mysql it's a little tricky, cause the access is protected with apparmor, you can copy /var/lib/mysql to dropbox and edit the data path in /etc/mysql/my.cnf, but to make it work you need to edit the app armor config check this link for details

I think that's all you need.

1

Rather than try and keep these files in Dropbox directly I would suggest using a tool such as rsync and a crontab entry to keep the different files backed up to your Dropbox folder.

Something like this:

rsync -avz /etc/apache2 /etc/mysql $HOME/Dropbox/mybackup/

A command like this can be expanded to include more files and directories as necessary. Additionally the command can be run from a crontab entry every few minutes/seconds.

On the other system you use rsync to "deploy" the files from your Dropbox to their real locations in /etc, /var, etc.

Your Answer

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

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