Thursday, October 8, 2009

Changing the document root in XAMPP

I know this has been covered many times before but I've found myself Googling for this info a number of times now and thought if I wrote it here then at least I'd know where to look next time!

After installing XAMPP on Windows, the document root, by default, is set to C:/xampp/htdocs (that is, if you installed xampp into the root of the C: drive).

In this particular case I wanted to change the root directory to the sites directory in my Dropbox (C:/Documents and Settings/[username]/My Documents/My Dropbox/sites/)

To do this, open xampp/apache/conf/httpd.conf and edit the 'DocumentRoot' setting (line 188 in the version I have) to the required path (as above). Several lines below where it says "This should be changed to whatever you set DocumentRoot to" (line 215) change the Directory path to the same thing.

Open xampp/php/php.ini and edit the 'doc_root' setting (line 804) to be the same path as above.

Save both files and restart apache. This should do the trick.

UPDATE: As pointed out in the comments, I'd forgotten about my MySQL data. To move the MySQL data into Dropbox:

Open xampp/mysql/bin/my.ini and:
- under [mysqld]:
- change datadir (line 30) to the full path to the mysql data directory on Dropbox.
- change log_error (line 45) to the same path as above PLUS '/mysql.err'.
- change general_log_file (line 48) to the same path as above PLUS '/mysql.log'.
- change slow_query_log_file (line 50) to the same path as above PLUS '/mysql-slow.log'.
- below where it says "Uncomment the following if you are using InnoDB tables"
- change innodb_data_home_dir (line 137) to the same path as above.
- change innodb_log_group_home_dir (line 139) to the same path as above.

Move contents of xampp/mysql/data into the new mysql data directory in Dropbox.

4 comments:

Anonymous said...

Cool, that'll work, but you'll miss your MySQL database and other stuff that resides in the XAMPP folder.

Why not sync the whole folder to your Dropbox instead?

http://lifehacker.com/5154698/sync-files-and-folders-outside-your-my-dropbox-folder

chad said...

Thanks so much! That helped!!

Ahad said...

Thank you very much. Is it possible to update this article?

Thanks,
Ahad

Anonymous said...

Thanks a lot