Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm new to Linux. just studying php/mysql development. On windows I kept Apache, PHP, Mysql, PgSQL directories in one folder on SEPARATE DRIVE, like this:

D:\server
    \mysql
    \apache
    \php

So - If I would to reinstall Windows - all I would have to do is start mysql and httpd services - and that's that. quick and easy. The same like XAMPP, except I don't need 20 extra apps that xammp give you.

I would love to do the same in Ubuntu. So I would keep apache,mysql,php on separate drive and start them whenever I want to (init.d or upstart to start them automatically).

so - the structure would be:

/media/storage/server
/media/storage/server/mysql
/media/storage/server/apache
/media/storage/server/php

I got everything compiled and setup aside from config files.

The problem is:

I want all config files to be in one place as well. I mean http.conf -in apache folder. my.cnf - in mysql folder

so - Question: How do I make MySQL load configuration file not from /etc/my.cnf, but from another arbitrary location. couldn't find this info anywhere..:(

important:

1)it's not a production server! It's just for someone who studyis web development and linux and doesn't want to keep reinstalling and reconfiguring server when he changes distros. 2) I know it's against Linux hierarchical standards. 3) I now about Ubuntu's tasksel lamp-server and/or XAMPP easinness:)

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Read http://dev.mysql.com/doc/refman/5.1/en/option-files.html after

On Unix, Linux and Mac OS X, MySQL programs read startup options from the following files, in the specified order (top items are used first).

share|improve this answer
    
Thanks. Not sure how I missed this one. I've ended up recompiling Mysql - because this way i can set up all paths to wherever I want and choose whatever settings I want. –  Stann Nov 20 '10 at 18:48

The easiest way to achieve your goals would probably be with simple symbolic links. Let the package create its configuration file wherever it wants to create them. Once that is done simply move the configuration files to where you want it, then create a symlink from the location where the package expect it to the folder where you want the config stored.

So if you installed the official mysql server package you would do something like this.

rsync -av /etc/mysql/ /media/storage/server/mysql/ #copy mysql config
rm -r /etc/mysql                                   # remove original folder
ln -s /media/storage/server/mysql /etc/mysql/      # create symlink to new folder

If you can commit to a single distribution for running your web stack then you may be able to make this easier on yourself by setting up a chroot environment. A chroot basically allows you to have a folder that has a self contained application and all the supporting libraries it needs. If you have the same architecure in multiple places you should be able to run things from that chroot on any system. Building a Debian/Ubuntu chroot is very easy I occasionally use it to allow me to have multiple different versions of a distro available on my system for testing things.

share|improve this answer
1  
chroot is really the right way to do this. You get to keep all the benefits of packaging, without worrying about fiddling with the symlinks (especially if you upgrade the packages). The only other option would be to basically forgo packaging, grab the source, configure it with --prefix=/media/storage/server/mysql/ --exec-prefix=/media/storage/server/mysql/ and compile and install it by hand. –  DerfK Nov 19 '10 at 0:39
    
mmm... Not exactly what I was looking for but thanks anyway. I've ended up compiling mysql from source because this way i can set config paths and data paths to any location as well as some other things. –  Stann Nov 20 '10 at 18:53

Your Answer

 
discard

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.