dqlhsm9820 2018-08-17 00:27
浏览 78

通过PHP启动Gameserver(和其他批处理文件)

I have a Windows Server with XAMPP (Apache 2.4 and PHP 7 running) and i want to build a PHP script that can start and stop a few game servers on the same machine.


I am struggling with the Minecraft Server right now, so let's take this as an example:

I have a folder called C:\_tekkitlite where the minecraft server is in. In these folder are these files (and a few others which are unimportant):

launch.bat
minecraft_server.jar
TekkitLite.jar

The C:\_tekkitlite\launch.bat has the following code in it:

java -Xmx3G -Xms2G -jar TekkitLite.jar nogui
pause

My current C:\_xampp\htdocs\startserver.php looks like this:

system('C:\_tekkitlite\launch.bat');

When I execute the line above, I get the following message

C:\_xampp\htdocs>java -Xmx3G -Xms2G -jar TekkitLite.jar nogui C:\_xampp\htdocs>pause Dr�cken Sie eine beliebige Taste . . .

The problem is that there is no java process running on the machine and consequently the minecraft server is offline.


When I change the C:\_xampp\htdocs\startserver.php to the following:

system('java -Xmx3G -Xms2G -jar C:\_tekkitlite\TekkitLite.jar nogui');

i get no message from php (i think because there is no pause at the end of this code) BUT i get a java process and a server running.

The problem is that you cannot join this server because it seems that the server doesnt do anything. Normally a minecraft server creates a bunch of files after starting, mine doesn't when I start it with the script above.


From now on, I dont know what to do. Did I make a mistake somewhere?

I think the permissions are not a problem because when I create a batch on C: with

echo "TestTestTestTest"
pause

php outputs this TestTestTestTest just fine.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多
    • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入