Re: Apache handler with Multiple PHP versions
| From: | Tijnema | Date: | Thu, 12 Jul 2007 12:17:45 +0000 |
| Subject: | Re: Apache handler with Multiple PHP versions | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-30863@lists.php.net to get a copy of this message | ||
On 7/12/07, Tijnema <tijnema@gmail.com> wrote:
On 7/12/07, chris# <chris#@codewarehouse.net> wrote: On Thu, 12 Jul 2007 11:38:44 +0200, Tijnema <tijnema@gmail.com> wrote:I just wrote a very simple test script, that does, I think, what it should do, it loads one of the different php libraries. --------------------php4.c-------------------- int parse_php_code(char *file) { return 4; } --------------------/php4.c-------------------- --------------------php5.c-------------------- int parse_php_code(char *file) { return 5; } --------------------/php5.c-------------------- --------------------php6.c-------------------- int parse_php_code(char *file) { return 6; } --------------------/php6.c-------------------- --------------------loader.c-------------------- #include <stdio.h> #include <dlfcn.h> int main(int argc, char *argv[]) { void *handle; char *error; int (*parse_code)(char *); if(argc != 2) { fprintf(stderr, "Syntax: %s <php module>\n", argv[0]); exit(1); } handle = dlopen(argv[1], RTLD_LAZY); if(!handle) { fprintf(stderr, "%s\n", dlerror()); exit(1); } parse_code = dlsym(handle, "parse_php_code"); if((error = dlerror()) != NULL) { fprintf (stderr, "%s\n", error); exit(1); } printf("%d\n",(*parse_code)("abc.php")); dlclose(handle); return 0; } --------------------/loader.c-------------------- I've compiled it like this: gcc -shared -fPIC php4.c -o libphp4.so gcc -shared -fPIC php5.c -o libphp5.so gcc -shared -fPIC php6.c -o libphp6.so gcc -rdynamic -o loader loader.c -ldl Now, I use the test program loader to load one of above compiled libraries: ./loader ./libphp4.so (Outputs 4) ./loader ./libphp5.so (Outputs 5) ./loader ./libphp6.so (Outputs 6) Now, to get back to the real world, libphp4.so, libphp5.so, and libphp6.so are the libraries compiled from PHP source, and the code of the loader would need to be integrated in the Apache2handler SAPI. So, I think this simple test shows that it is possible on Linux (atleast on my linux-2.6.17.11, Glibc-2.3.6, gcc-4.2.0), or did I forgot something else? Regards, TijnemaHello Richard, On 7/12/07, Richard Lynch <ceo@l-i-e.com> wrote:This is no more unusual that adding/eliminating directory access. Which is pretty common stuff for users on a hosting companies box. Extremely simple too. The hosting outfit will /surely/ indicate any changes they need to make to provide them with the /added/ functionality. Maybe even add an applet in the Cpanel for it. My host hasn't a single .htaccess file ;) (Using DirectAdmin..)1) Did you ever see a shared host that has multiple versions configured like this? 2) This will end up to be confusing for the end user, as they will need to create the .htaccess file (as most users don't have write rights for httpd.conf)On Wed, July 11, 2007 6:13 pm, Tijnema wrote:On 7/12/07, Jani Taskinen <jani.taskinen@sci.fi> wrote:Hello Jani: I know this is possible, and I believe it is possible in Apache too with some kind of hack? But this still doesn't solve a lot of problems, but will generate a lot more with portable code. Take a bulletin board for example, there are a lot of files inside a board, and when you want to install that on your host that has PHP5 for files with .php5, you need to rename a hell lot of files to .php5, AND change code inside the .php5 files to point to the renamed files.A lot easier (and works already) is to install PHP as CGI/FastCGI (one version or all of them, one can be module of course) and define the required PHP version by the file suffix.. --JaniNo, you add a <Directory> config in httpd.conf or add to .htaccess a line like <Files ~.php> ForceType whatever/gets/you/to/php-5 </Files>Yes, you are. All OS's handle loading differently. An experience I read about indicated that it works fine with the BSD family of OS's but not with (at least) Linux. of course they do, I was only thinking about linux. I always thought that it was possible in Linux too, as the dlopen function is available, and should work like that.Both modules are different files, and only one will be dynamically loaded by dlopen(), that works fine right? or do I forget something?Other problems: Getting 2 PHP modules to co-exist without tromping on each others' symbols is, I think, the show-stopper...