settingsun;10990497 wrote:If I can see the php code itself in the source, the php is not being parsed, and a security vulnerability exists - Got it
Yup. That's why you might run into a situation where someone suggests you store a PHP config file "above your web root," which essentially means any folder that doesn't have /var/www/html/ as an ancestor.
The idea is that if something were to happen to the webserver config and PHP files started getting spit out as plain text, sensitive files (such as those containing DB credentials and whatnot) would still be protected in the sense that it wouldn't be possible to simply request them directly from the webserver.
settingsun;10990497 wrote:What do these lines really mean or really do?
AddHandler php5-script .php
This is telling Apache that any time a request ends up pointing to a file ending with ".php" it needs to invoke the handler called "php5-script" rather than simply serving up the file as plain text (or whatever else it had planned on doing).
This handler is defined by the PHP CGI interface (php-cgi) rather than the module interface (.so/.dll for *nix/Windows). Note the comments on using CGI in the PHP manual here: [man]install.unix.commandline[/man].
See the Apache manual for more info: AddHandler.
AddType text/html .php
This tells Apache that requests that end up being fulfilled by files with a ".php" extension should result in a Content-Type header value of "text/html". This is rather unnecessary, however, since PHP can already override the MIME type on-the-fly via the "default_mimetype" directive (see PHP manual: Data Handling).
Again, see the Apache manual for more info: AddType
AddType application/x-httpd-php-source .phps
This is an alternative way of telling Apache how it should handle files as compared to the AddHandler approach above. Instead, this is overriding the MIME type of files with a ".phps" extension and forcing it to be "application/x-httpd-php-source".
If using the CGI, you'll probably also have an "Action" directive in there to tell Apache what it should do for files of type "application/x-httpd-php-source" (since it otherwise doesn't know what to do with such a file).
If using the ISAPI module, this type is registered by the PHP source handler (meaning that Apache will know just based on the MIME type that it should pass ".phps" files on to the PHP source highlighter).
However, step #8 in the Unix install instructions for PHP caution against using the AddType directive due to the possible security risk it presents for files with so-called "multiple extensions" (which I personally find to be a misnomer.... a file consists of a file name (optional, e.g. ".htaccess"), which can include all sorts of characters including periods, and a single extension).
In other words, you wouldn't want someone uploading some dangerous PHP code, calling it "my_script.php.jpg", and then Apache ends up passing it to the PHP interpreter anyway simply because it had ".php" somewhere in the name. Because AddHandler doesn't interpret "multiple extensions," the method you have above for .php files is fine.
settingsun;10990497 wrote:What kind of file has a .phps extension?
PHP Source files. Basically, take any .php file, rename it to have a .phps file extension, and instead of parsing and executing it PHP will simply output a highlighted version of the raw PHP source code as an HTML document. Also see related PHP functions [man]highlight_file/man/[man]highlight_string/man.