如何通过 Apache 在另一个进程中运行 CGI 脚本
我有一个执行非常密集的 Java 应用程序的 CGI 脚本:
start.cgi#!/bin/sh
cd /var/服务器/; screen -d -m java -Xmx800M -Xms800M -jar jarfile.jar > /dev/null 2>&1 &
echo "已执行服务器命令。";
通过在 Internet 浏览器中并通过 SSH 会话导航到该命令,该命令可以正常执行。
但是当通过互联网浏览器导航到它来运行时,它似乎在 apache 进程下运行...... top
的输出:PID 用户 PR NI VIRT RES SHR S %CPU %MEM TIME+ 命令
7651 apache 24 0 1149m 38m 9012 S 0.0 2.5 0:01.42 java
通过 SSH 会话运行时 top
输出:PID 用户 PR NI VIRT RES SHR S %CPU %MEM TIME+ 命令
7685 root 23 0 1163m 205m 9432 S 12.3 13.6 0:06.03 java
我相信CGI脚本正在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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能必须 chmod 您的脚本文件才能将 uid 设置为 root - 但我不得不说这不是一个好主意。以 apache 而不是 root 身份运行的作业是否存在问题?当然,它从 ssh 会话以 root 身份运行的唯一原因是因为您已以 root 身份登录?
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?