bash 尝试使用“heroku run”运行php文件,我得到“bash权限被拒绝”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14389140/
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
Trying to run php file using "heroku run" and I get "bash permission denied"
提问by Andrew Samuelsen
I'm trying to run a file with heroku run path/to/file.phpand I get a reponse:
我试图运行一个文件,heroku run path/to/file.php我得到了一个回应:
bash: path/to/file.php: Permission denied
bash: path/to/file.php: 权限被拒绝
I've tried chmod 755on the file and directory, but it seems that heroku changes it back to 600... After running chmod 755it shows 755, but then when I exit bash and then come back the permissions are reset to 600.
我已经尝试chmod 755过文件和目录,但似乎heroku将它改回600......运行chmod 755后显示755,但是当我退出bash然后回来时,权限被重置为600。
What am I missing?
我错过了什么?
Also some people have suggested
也有人建议
heroku run php path/to/file.php
but I get an error saying
但我收到一条错误消息
bash: php: command not found
bash: php: 命令未找到
回答by friism
There are a couple of things you need to do.
您需要做几件事。
- When creating the Heroku application, you have to make sure that the PHP buildpack is used. This is what will inject the PHP runtime into your application slug. Either add a
index.phpfile (which is how PHP is detected) or hard-code it like this:heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git - Set the library path as detailed in this question: heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
- Run your stuff:
heroku run ./php/bin/php --version
- 创建 Heroku 应用程序时,您必须确保使用 PHP buildpack。这就是将 PHP 运行时注入您的应用程序 slug 的内容。添加一个
index.php文件(这是检测 PHP 的方式)或像这样硬编码它:heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git - 按照本问题中的详细说明设置库路径:heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
- 运行你的东西:
heroku run ./php/bin/php --version
To sum up:
总结:
heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php.git
heroku config:add LD_LIBRARY_PATH=/app/php/ext:/app/apache/lib
heroku run ./php/bin/php --version
A useful way to debug this is to bash into the running Heroku dyno: heroku run bash. That will let you poke around, see where things are at and experiment.
一个有用的调试方法是 bash 进入正在运行的 Heroku dyno: heroku run bash。这会让你四处看看,看看东西在哪里并进行实验。
回答by hohner
Have you tried running the command with sudoprivileges:
您是否尝试过以sudo特权运行命令:
sudo heroku run path/to/file.php
If your shell can't use the phpcommand (i.e. its alias), you will need to provide the absolute path:
如果您的 shell 不能使用该php命令(即它的别名),您将需要提供绝对路径:
sudo /usr/bin/php path/to/file.php
That's where it's usually located. To find your PHP bin location, try:
那是它通常位于的地方。要找到您的 PHP bin 位置,请尝试:
whereis php

