Does server software execute server side scripting directly?

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
Hello,

Generally, does server software execute server side scripting directly, or is there a separate layer for executing server side scripts.

Specifically, does Apache execute PHP scripts directly, or is the PHP engine a separate layer?

Thanks.
 

BoberFett

Lifer
Oct 9, 1999
37,562
9
81
I've been out of the coding game for a while but unless things have changed...

There may be exceptions for web servers written specifically to interpret scripts for performance, but typically the interpreter is a separate process. PHP, ASP, Java (server side), Perl, Ruby, ColdFusion, are all sent to a separate interpreter by the web server. Some are probably a bit more tightly integrated together such as IIS/ASP, but they're still technically separate and it would be possible to use any interpreter that could run the script.
 

Cogman

Lifer
Sep 19, 2000
10,284
138
106
It really depends on the tech involved. Apache, for example, can do anything from "call python.exe to run all things with .py as their extension" to "when you encounter .php use the php plugin".

The difference between the two is the difference between spinning up a new process (slow) and calling off to an integrated plugin (fast).

In the Java world, things are often even faster. Jetty, Tomcat, or Glassfish tie very closely to the java servers that they are running with the calls being fairly optimized.

In the case of PHP, it depends on how the server is setup. PHP can either be executed as a separate process or as a plugin depending on the setup.
 
Feb 25, 2011
16,992
1,621
126
As has been mentioned, it's complicated.

I just want to chime in to point out that, at least so far as I've experienced, the user account that runs the web server is generally also the user account executing the scripts. So from an access control perspective (can you tell I'm a server admin and not a programmer?) the server software executes the scripts "directly." Or at least as directly as, say, you double-click an attachment in your email program and it opens up a PDF file in Adobe.

So be sure you set file ownership and privileges of your scripts such that the www user can execute them, and has necessary permissions for any output directories, etc.