[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PHP] Placement of PHP programs?



Matthew Palmer wrote:
> As a kind of an adjunct to the other discussion on PHP libraries, what about
> PHP programs?  Not quite so touchy, as I can't see a single way forward here
> (and there's no blazingly obvious reason to do so).  So what are people's
> best thoughts on the matter?  Most packages I've seen put their
> web-accessible content in /usr/share/<package>, then either set up a
> separate apache config and include it from the main apache config
> (phpgroupware does it this way, for one example) while other packages modify
> apache.conf more intrusively.  I'm a fan of the phpgroupware method, which
> at least minimises pain.

The best thing would probably to split such a package properly:

/etc/$package/                for an apache.conf file and package configuration
/usr/share/$package/root/     for the DocumentRoot for this package
/usr/share/$package/include/  for additional include files[1]
/usr/share/$package/data/     for additional data files
/usr/share/doc/$package/      for documentation

Since PHP files, include files and data files are not arch-specific,
static and belong to a package they should be placed inside of the
/usr directory and not inside the /var directory

A PHP package should not install or link into /var/www directly since
that's where the user/admin most likely places his own web pages.  I
won't feel very happy if random PHP packages would install themselves
inside of existing web space, especially if they are likely to be used
with a virtual host on their own.

> But what if people are using a different Web server?  It's possible, so why
> are we blindly assuming apache?  Should we cater for the default, and anyone
> doing differently should know enough to fix the problem themselves?  That's
> a possibility.

I'd say, include an apache.conf because Apache is the most widely used
webserver that runs PHP.  You'd probably be very kind if you would
include configuration snippets for all available web servers, though,
I wonder if it's worth the effort.

> And what about where in the docroot we put our program for accessability? 

In general it should not matter since you should probably use relative
pathnames within the namespace of the particular package.  Hence if it
is installed in /, the files are referenced as /foo.php, however, if
they're mapped into the web server as /bar/, then all files will be
referenced as /bar/foo.php.

Since the user needs to map the package into his own namespace, either
in his main web space in /var/www or into one of his virtual hosts,
but that's really an issue of the user.  I don't think a package could
find out all possibilities of Apache configurations and (virtual)
hosts configurations to add itself into the proper one.  Hence, I'd
say, leave it to the admin.

Footnote:

 1. Include files should not be executable on their own and hence
    should not be placed inside the web tree directly

Regards,

	Joey

-- 
Every use of Linux is a proper use of Linux.  -- Jon "Maddog" Hall

Please always Cc to me when replying to me on the lists.



Reply to: