Using a PEAR-installed web application on multiple vhosts
| From: | Christian Weiske | Date: | Thu, 26 Aug 2010 06:30:44 +0000 |
| Subject: | Using a PEAR-installed web application on multiple vhosts | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-53727@lists.php.net to get a copy of this message | ||
Hi all,
The following problem has been discussed in IRC without avail, so I'm
bringing it here for enlightenment of us:
Last weekend I packaged up SemanticScuttle, a web-based bookmark
manager, into a pear package - Files separated in www, test, php, data
and doc files. It needs to be configured before it can be used, i.e.
database connection details and administrator users need to be set.
Now I imagine the workflow of setting up an instance of the bookmark
manager for a user vhost on that machine as follows:
1. User asks admin: "Hey, I want to use SemanticScuttle. There is a
pear package, please install it."
2. Admin discovers channel and installs PEAR package system wide. This
allows central updates by the administrator just like the "normal"
package system does.
3. User writes a config file into his vhost directory.
4. ????
Up to now I thought that just symlinking the user's vhost
directory /home/username/www/bookmarks.example.org/ can be symlinked to
$pear_www_dir/application/, making all www-relevant files available in
the vhost.
Unfortunately, this does not allow the user to configure the
application by creating a config file in the vhost directory.
Configuration is the central problem here: How does the user configure
the application in each vhost?
Several ideas:
0. vhost directory is symlinked to www_dir/app, config file is stored in
PEAR's cfg directory.
Downside:
- User cannot change settings (blocker!)
- Multiple instances have the same config.
1. as in 0, but config file name depends on $hostname
Downside:
- User cannot change settings (blocker!)
2. The user vhost directory is a symlink to the www_dir/$app folder.
The application www files load the config from "../config.php". This
would load the config file from
/home/username/www/bookmarks.example.org/../config.php, thus
/home/username/www/config.php - making symlinking the www files
possible.
Downside is that multiple instances of the same application for the
same user is not possible since all use the config.php file in ~/www/
Also, some httpds do not tell you the original path but the
realpath, giving you $www_dir/app instead of /home/username/...
3. Combination of 2 and 1: config file is loaded from ../, with a
file name that contains the hostname or IP
4. vhost dir is a normal directory, config.php resides within.
All files from www_dir/app are symlinked into that vhost directory.
Plus:
- Config file is where it is needed, no problem locating it
- No need to care about $hostname and $ip or server aliases for
config file name.
Minus:
- Updating the application might bring new files and remove old files
in www_dir/app. Those would need to be symlinked manually by the
user.
5. Make use of pear's two-tier config file hierarchy: user and system
config. With pyrus, one could use a custom user cfg dir for each
user or each vhost.
Downside is that for every http request, the cfg dir needs to be
determined from the pearrc files, adding massive overhead.
All methods listed here are not really comfortable. Other ideas?
--
Regards/Mit freundlichen Grüßen
Christian Weiske
-=≡ Geeking around in the name of science since 1982 ≡=-