No doubt PHP is the best tool a web developer can have and if you develop applications on Windows you must have heard of Wamp Server. (Those who don’t know Wamp let me tell you it can setup your local environment in minutes to start developing your applications). There are many tasks we used to repeat daily or many times a day.
- Pull from server – in case you are using GIT
- Push to the Server – in case you are using GIT
- backup database
- backup files
- Sync Files – in case you are using two development machines e.g. laptop, PC.
- System got damaged then again developing from scratch because you forgot to backup. The worst one happened to me. 🙁
- so on …
I also used to repeat these steps many times a day. Now my question was why to repeat same process every time, When they can be automated easily? So I came up with an Idea. I was already using Dropbox for backing up my documents and PHP files. (If you don’t know about Dropbox go to their website and take a tour; you are missing a money & time saver). But one day i came with an idea of syncing my databases using Dropbox. Here are the steps you can follow to keep your localhost synced, secure and controlled by dropbox’s strong version control system.
- Setup and install Wamp Server. To download one follow the link.
- Setup and install Dropbox. Follow the link to download. (If you will follow this link you and me both would get 250MB extra space. By default Dropbox provide 2GB of storage. You would get 2.25GB from this link.)
Main Configurations Start from here.
Now Apache needs to be informed to store and use Dropbox as root directory:
- Create a folder named ‘www’ in dropbox folder and tell Apache to use this folder as root.
- This we do by editing Apache’s httpd.conf file. If you installed Wamp Server with its default settings, this file should be located at ‘C:wampbinapacheApache2.2.21confhttpd.conf’. (version may vary).
- Open this file in notepad or any editor you use. Search for the word “DocumentRoot” or the line looks similar to (most probably line no 178):
- Change it to :
- Notice the slashes used, only forward slashes can be used don’t use backward slashes.
- On around line no 205 you will find :
- Change it to :
- Save and close the files.
Now you have saved all your files on the cloud which is enabled with Automatic Version system, Automatic Backup, Automatic Sync. Lets proceed to the database:
- Open the file my.ini located in “C:wampbinmysqlmysql5.5.20my.ini“and find a variable declaration datadir (line no: 39) and change its address to “C:/Users/Abhishek/Dropbox/database/“.
- In the same folder you would find a folder named data copy its content to the following location “C:/Users/Abhishek/Dropbox/database/“.
- Restart your Wamp server.
You have configured your localhost to stay synced with dropbox. And dropbox keeps all your devices synced. Just follow the steps on all your devices.
Note: Never delete the content of folder in “C:wampbinmysqlmysql5.5.20data“.