Hello and good evening,
on a CentOS Linux server I run 3 instances of Jetty on 3 different IP addresses, serving a servlet and Wordpress in 3 different languages: English, German, Russian.
And the Jetty instances are started by /etc/systemd/system/jetty-en.service (and jetty-de.service at port 8081, jetty-ru.service at 8080):
[Unit]
Description=Jetty
After=network-online.target
Type=simple
User=jetty
Group=jetty
ExecStart=/usr/bin/java -Djdbc.drivers=org.postgresql.Driver -jar /usr/share/java/jetty-distribution-9.4.27.v20200227/start.jar jetty.home=/usr/share/java/jetty-distribution-9.4.27.v20200227 jetty.base=/var/www/jetty-base-en jetty.http.host=127.0.0.1 jetty.http.port=8082
SuccessExitStatus=143
Restart=always
RestartSec=180
PrivateTmp=true
[Install]
WantedBy=multi-user.target
As you can see above I pass some information through the env. variables to the custom Java servlet of my word game.
The above stuff works well, but now I am also trying to pass some configuration information to the few PHP scripts I am also running - and unfortunately this does not work - when I print($_ENV['COUNTRY'); in the PHP scripts, the env. variable is not there.
Is there please a way to pass the env. vars from Jetty process to the PHP scripts run through FastCGI?
The reason why I am asking is that I am trying to reuse as much source code (Java, PHP, _javascript_) while serving my word game in 3 different languages.
Thank you
Alex
PS: Below is my Jetty config xml file:
# cat /var/www/jetty-base-en/webapps/wordsbyfarber.com.xml
<New id="root" class="java.lang.String">
<Arg>/var/www/html/
wordsbyfarber.com</Arg>
</New>
<Set name="contextPath">/</Set>
<Set name="resourceBase"><Ref refid="root" /></Set>
<Set name="welcomeFiles">
<Array type="string">
<Item>index.php</Item>
<Item>index.html</Item>
</Array>
</Set>
<Call name="addFilter">
<Arg>org.eclipse.jetty.fcgi.server.proxy.TryFilesFilter</Arg>
<Arg>/*</Arg>
<Arg>
<Call name="of" class="java.util.EnumSet">
<Arg><Get name="REQUEST" class="javax.servlet.DispatcherType" /></Arg>
</Call>
</Arg>
<Call name="setInitParameter">
<Arg>files</Arg>
<Arg>$path /index.php?p=$path</Arg>
</Call>
</Call>
<Call name="addServlet">
<Arg>
<New class="org.eclipse.jetty.servlet.ServletHolder">
<Arg>default</Arg>
<Arg>
<Call name="forName" class="java.lang.Class">
<Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
</Call>
</Arg>
<Call name="setInitParameter">
<Arg>dirAllowed</Arg>
<Arg>false</Arg>
</Call>
<Call name="setInitParameter">
<Arg>gzip</Arg>
<Arg>true</Arg>
</Call>
</New>
</Arg>
<Arg>/</Arg>
</Call>
<Call name="addServlet">
<Arg>org.eclipse.jetty.fcgi.server.proxy.FastCGIProxyServlet</Arg>
<Arg>*.php</Arg>
<Call name="setInitParameter">
<Arg>proxyTo</Arg>
<Arg>
http://localhost:9000</Arg>
</Call>
<Call name="setInitParameter">
<Arg>prefix</Arg>
<Arg>/</Arg>
</Call>
<Call name="setInitParameter">
<Arg>scriptRoot</Arg>
<Arg><Ref refid="root" /></Arg>
</Call>
<Call name="setInitParameter">
<Arg>scriptPattern</Arg>
<Arg>(.+?\\.php)</Arg>
</Call>
</Call>
</Configure>