PHP Velho Oeste 2024

Caso 4: El analizador de PHP fuera del árbol de la web

Una opción muy segura es poner el binario analizador de PHP en algún lugar fuera del árbol de ficheros de la web. En /usr/local/bin, por ejemplo. El único inconveniente real con esta opción es que ahora tendrá que poner una línea similar a:

#!/usr/local/bin/php
como la primera línea de cualquier fichero que contenga etiquetas de PHP. También necesitará hacer que el fichero sea ejecutable. Eso significa, tratarlo exactamente como trataría cualquier otro script de CGI escrito en Perl, sh, bash, o cualquier otro lenguaje común de script el cual utilice #! como mecanismo de ejecución de si mismo.

Para que PHP maneje la información correctamente de PATH_INFO y PATH_TRANSLATED con esta configuración, La directiva ini cgi.discard_path debe estar habilitada..

add a note add a note

User Contributed Notes 2 notes

up
-7
Anonymous
10 years ago
To add a new structure out the PHP directory, you have to do first:

- Configure the .ini file
- Add to your IDE the interpretor
up
-9
terom at fixme dot fi
10 years ago
You can use binfmt-misc to avoid the need for the #! line, by registering your php5-cgi binary as an interpreter for *.php files. E.g. with Debian binfmt-misc installed:

    update-binfmts --install php5 /usr/bin/php5-cgi --extension php
    cat /proc/sys/fs/binfmt_misc/php5

However, you still need chmod +x on the .php file. And Apache will give a rather sad "500 Internal Server Error" if you are missing the +x permissions :( You can improve the error message using mod_rewrite (but not obliviate the need for +x)..
To Top