从哪里开始使用 CPanel 托管在 PHP 中运行命令行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10339485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 21:57:50  来源:igfitidea点击:

Where to start with running a command line in PHP with CPanel hosting

phpshellcommand-linecpanel

提问by penpen

I'm having a look at some PayPal scripts/code examples and a lot of them need a php script running via the command line.

我正在查看一些 PayPal 脚本/代码示例,其中很多需要通过命令行运行的 php 脚本。

I've never had to run anything from a command line in PHP before so don't know where to start at all. I don't know if I'm using the correct search terms as Google hasn't helped me answer.

我以前从来没有在 PHP 的命令行中运行过任何东西,所以根本不知道从哪里开始。我不知道我是否使用了正确的搜索词,因为 Google 没有帮我回答。

Do I need to use a different application or is there something in cPanel I can use?

我需要使用不同的应用程序还是我可以使用 cPanel 中的某些内容?

I get this error:

我收到此错误:

INSTALLATION ERROR: Please cd to the /home/site_name/public_html/site and run install.php

采纳答案by Doug Molineux

Use SSH to access the server via the terminal:

使用 SSH 通过终端访问服务器:

http://docs.cpanel.net/twiki/bin/view/11_30/CpanelDocs/ShellAccess

http://docs.cpanel.net/twiki/bin/view/11_30/CpanelDocs/ShellAccess

There's instructions on how to connect via PuTTY, then you can go to the directory where the PHP script is run it like:

有关于如何通过 PuTTY 连接的说明,然后您可以转到运行 PHP 脚本的目录,如下所示:

php myPHPScript.php

php myPHPScript.php

回答by Bibhas Debnath

Ifyour cPanel has the option to turn on SSH, do it. Then SSH into the server and run the commands -

如果您的 cPanel 可以选择打开 SSH,请执行此操作。然后通过 SSH 连接到服务器并运行命令 -

cd /home/site_name/public_html/site
php install.php