简体   繁体   中英

How to run a CGI script in another process through Apache

I have a CGI script that executes a very intensive Java application:

start.cgi
#!/bin/sh
cd /var/server/; screen -d -m java -Xmx800M -Xms800M -jar jarfile.jar > /dev/null 2>&1 &
echo "Server command executed.";

This executes just fine by navigating to it in an internet browser and through an SSH session.

But when run by navigating to it with an internet browser, it seems to run under the apache process... Output of top :
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7651 apache 24 0 1149m 38m 9012 S 0.0 2.5 0:01.42 java

When run via an SSH session top outputs:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7685 root 23 0 1163m 205m 9432 S 12.3 13.6 0:06.03 java

I believe the CGI script is running under the apache process...
Can someone please point out what I have done wrong or point me in the right direction?

Thanks!
Justin

You may have to chmod your script file to set the uid as root - but I'd have to say that that is not a great idea. Is there a problem in the job running as apache rather than root? Surely the only reason that it runs as root from an ssh session is because you have logged in as root?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM