Executing PHP scripts with OSU web server.


Topic author
jonesd
Master
Posts: 108
Joined: Mon Aug 09, 2021 7:59 pm
Reputation: 0
Status: Offline

Executing PHP scripts with OSU web server.

Post by jonesd » Sun Sep 29, 2024 4:46 am

I haven't seriously looked at PHP since 2007 (version 4.4.7), but a thread on comp.os.vms nudged me to take another look since VSI has a PHP kit. The SAPI module interface doesn't appear to have changed too much so it wasn't that much work to get the old custom interpreter to build against the 8.0.10 library (PHP$SHR). The reason for the custom interpreter is that it can build the CGI environment directly as PHP variables without the limitations inherent with mapping them to DCL symbols and/or logical names (cgi_symbols.exe).

The attached zip file has 3 files:
  • script_code/php_cgilib.c (source file for interpreter)
  • script_code/php.opt (linker options file to link php_cgilib.obj with cgilib and PHP$SHR)
  • script_code/descrip.mms (updated MMS file to build php.exe and copy to [-.system])
Placing this custom php.exe in www_system should make WWWEXEC.COM automatically use it to process .php files in the exec directory (e.g. /htbin/phpinfo.php). If you want to be more expansive, place php.exe itself in the exec directory (www_root:[bin]) and any .php file accessible to the server can be executed (e.g. /htbin/php.exe/~smith/personal.php).
Attachments
osu_php_001.zip
Custom PHP interpreter for OSU web server.
(11.74 KiB) Downloaded 161 times

User avatar

arne_v
Senior Member
Posts: 529
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Executing PHP scripts with OSU web server.

Post by arne_v » Fri Oct 04, 2024 9:41 am

I have always assumed that mberryman was him.

Recent thread:

https://forum.vmssoftware.com/viewtopic.php?f=12&t=9189
Arne
arne@vajhoej.dk
VMS user since 1986

User avatar

cct
Master
Posts: 215
Joined: Sat Aug 15, 2020 9:00 am
Reputation: 0
Location: Cambridge, UK
Status: Offline

Re: Executing PHP scripts with OSU web server.

Post by cct » Fri Oct 04, 2024 9:58 am

Ah - missed that one!
Chris Townley
VMS Ambassador


Topic author
jonesd
Master
Posts: 108
Joined: Mon Aug 09, 2021 7:59 pm
Reputation: 0
Status: Offline

Re: Executing PHP scripts with OSU web server.

Post by jonesd » Fri Oct 04, 2024 10:14 am

arne_v wrote:
Fri Oct 04, 2024 8:29 am
But the ability to build a thread safe version is very old - like 25 years old. Even if VMS C may not build it, then maybe VMS x86-64 clang may build it.
It appears to have gone through a couple iterations of how to support thread safety and tries to accommodate different implementation models, This leaves the code cluttered up with macro invocations such as "SG(request_info).response_code = 200;" (set the thread local global request_info.response_code to a value of 200).

User avatar

arne_v
Senior Member
Posts: 529
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Executing PHP scripts with OSU web server.

Post by arne_v » Fri Oct 04, 2024 11:38 am

And we don't have thread local storage.

Code: Select all

$ type tl.c
#include <stdio.h>

int main(int argc, char *argv[])
{
    __thread int v = 123;
    printf("v = %d\n", v);
    return 0;
}
$ cc tl

    __thread int v = 123;
.............^
%CC-E-NOSEMI, Missing ";".
at line number 5 in file DKA0:[arne]tl.c;2

    printf("v = %d\n", v);
.......................^
%CC-E-UNDECLARED, In this statement, "v" is not declared.
at line number 6 in file DKA0:[arne]tl.c;2
$ clang tl.c
tl.c:5:5: error: OpenVMS does not currently support thread_local/__thread/_Thread_local declaration specifiers
    __thread int v = 123;
    ^
1 error generated.
(edited to have the int type)

Added in 1 hour 13 minutes 5 seconds:
And now I remember that VSI has actually told us so:

https://forum.vmssoftware.com/viewtopic ... 157#p21866
Last edited by arne_v on Fri Oct 04, 2024 11:43 am, edited 1 time in total.
Arne
arne@vajhoej.dk
VMS user since 1986


mberryman
Active Contributor
Posts: 43
Joined: Sat Sep 02, 2023 1:31 pm
Reputation: 0
Location: Colorado Springs, CO, USA
Status: Offline

Re: Executing PHP scripts with OSU web server.

Post by mberryman » Fri Oct 04, 2024 1:45 pm

I have never tried to build a thread-safe version of PHP for a few reasons.

1. Doing so requires that the compiler support thread-local storage, which is not currently available on VMS.
2. PHP uses signals and, in a thread-safe version, probably requires them to be thread-specific instead of process-wide.
3. I've never encountered a situation where a threaded version was needed on VMS.

It appears that you have tried Apache and OSU. Have you tried WASD? That is the web server I use and I have been happy with its performance.

User avatar

arne_v
Senior Member
Posts: 529
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Executing PHP scripts with OSU web server.

Post by arne_v » Fri Oct 04, 2024 3:06 pm

I have not tried WASD but maybe I should.

How does WASD PHPRTE work?

Based on a quick reading of the docs it looks like:
* multiple script processes
* each running an RTE EXE with embedded PHP
* each processing multiple requests for PHP serially

Is that correct?
Arne
arne@vajhoej.dk
VMS user since 1986

Post Reply