Allow Glassfish and PHP to work together on the same server using Apache

Is it possible to make a bridge from Java to php file?

I have an application written in Java and I need to run http://piwik.org/ , which is written in PHP. PHP is running on my server, but I can’t get access from the browser to the php directory, because all incoming traffic is redirected by apache to the Glassfish application server.

So my idea is to use a Java servlet to execute php files with:

Runtime.getRuntime().exec("php /path/to/file/file.php");

Then write the PHP output as the response of the Java servlet.

The only problems for this:

How can I execute PHP cli that act as a browser?

What parameters do I need to pass to PHP so that PHP can read or write cookies and session?

+4
3

Apache -, Piwik / mod_php/php-fpm/ .

php-cgi , , , . Apache , , Apache.

:

ProxyPass /piwik ! 
ProxyPass / 127.0.0.1:8080 
ProxyPassReverse / 127.0.0.1:8080
+4

PHP , GET/POST/SESSION/COOKIE . file.php cookie, , .

, CGI SAPI, HTTP_* , .

php-cgi CGI, cookie :

HTTP_COOKIE='PHPSESSID=XXXX' php-cgi /path/to/file/file.php

XXXX . cookie, .

+4

kelunik Apache . Federico , Apache:

ProxyPass /phpdir ! 
ProxyPass / 127.0.0.1:8080 
ProxyPassReverse / 127.0.0.1:8080

Apache redirects the entire request to port 8080, except for the / phpdir folder . To the root of the Apache document, I created the phpdir directory , which is the new root where PHP applications will run.

What he

+2
source

Source: https://habr.com/ru/post/1625149/


All Articles