13 Augustus 2009
Installing Drupal 6 server-wide was not an easy job.
I write this article hoping Drupal 7 will have
Multi-site <> (Server-wide || Direct Admin)
Drupal supports a multi-site installation. But then we could not give our clients an own hosting-account. Since our DirectAdmin had no way to handle this properly, we looked further. Without finding any solution.
I am also a great supporter of having everything outside the webroot. Only the real public-items should be in the public level.
So we started hacking around. It took alot of time and energy but with great succes! Not everything is automated as in the normal installations but that is no problem to us, programmers ;-)
Our server-wide solution
To get the job done we made serveral constants for each important Drupal-directory. Then we developed an advanced php-class to handle the path-request from any drupal-script.
The class is looking through the directories in a certain order. If it founds the requested path returned. In the meanwhile the class builds it list with paths to get some caching.
Advanced complete control!
We wanted complete control over any important dir. So with init.inc (both client and global) we have all those constants to define each path. So if, and only if there comes a reason to change directories we cán do this without any hacking anymore!
Relative paths
Drupal saves many paths in the database. This is really annoying and a problem when copying to an other domain. We fixed this also. Whenever Drupal 6 writes a path to the database, it is made relative.
Lately I still found some absolute paths in a table. So I overlooked something I guess. Luckily it was no problem for now.
No hard-coding
Hardcoded paths should not be allowed. Getting a path was mostly done by some core functions. But also these functions should get there input only, yes only!, from the init-settings.
Directory setup
The directories for Drupal are split into 3 sections:
- drupal-core
- drupal-client root
- drupal-client public
The drupal core code is put into its own server-account and can hold more versions. It is like:
- /home
- /drupal
- /drupal_001
- /drupal_002
- /drupal
Each drupal_xxx version directory holds:
- init.inc (the global init settings, constants etc.)
- /includes
- /modules
- /misc
- /themes/engines (only the engines!)
- /js
- /public (with update.php, cron.php etc.)
Styles and javascript in the core?
That is no problem when you have server-access ;-)
We created some symlinks in every virtualhost.
/dpl/ goes to /home/drupal/drupal_xxx/
Symlinking is easy done, but hacking it into Drupal 6 was quite difficult. But of course the paths-class is set to handle this. The only thing he needs to know is if the calling drupal-script needs an intern path to something or that it is an http-path.
Public, webroot, global or client?
The paths-class can be told to get the public path or the root-path. Cause checking if a stylesheet exists or getting the url to the stylesheet needs different path.
A directory like /themes is found in the drupal-core, the client-root and in the public-root. Based on priorities of the different paths the class will decide which path to return.
Third party scripts
When a module or drupal script uses a third party source like smarty or fckeditor it wants the source inside a specific static directory. Any request to this directory is hard coded.
Except for Smarty, I have left this as it was. But it would be so much better, when these paths also could be configured.
Client account setup
Setting up a client is easy now. Ok, it is not automated yet ;)
It is like copy-and-paste. Take an existing database. Clean it.
Copy some dirs from an other account.
Change its init.inc and it works.
Client directory structure
- client-root
- /drupal
- init.inc
- settings.php (init and settings should be merged)
- /themes (only .info, templates and php-includes)
- /domaintmp 777 (a tmp-directory)
- /rootfiles 777 (the private files-directory)
- /cache 777
- /www_root
- index.php
- /themes (with stylesheets and images etc)
- /drupal

De getoonde blog hier links is voor de techneut die het belangrijk vindt dit soort informatie te lezen.