在PHP中使用shell_exec geogig init时权限被拒绝

时间:2016-03-27 15:40:13

标签: php permissions

嗯,GeoGig它是一个用于版本化地理数据的新工具,它具有与git相同的功能。 我正在实现这个新工具但是当我使用shell_exec(“geogig init”)时我遇到了问题。 我在apache中设置了PATH变量,它指向/ opt / geogig / bin,geogig的二进制文件在哪里,我可以在我的php中使用命令行geogig。 我的问题是这个命令创建了本地存储库的某个部分,但是得到了一个shell_exec抛出的错误:

12:15:33.678 [main] ERROR o.locationtech.geogig.cli.GeogigCLI - An unhandled error occurred: java.io.IOException: Permission denied. See the log for more details.
org.locationtech.geogig.storage.ConfigException: java.io.IOException: Permission denied
    at org.locationtech.geogig.storage.fs.IniFileConfigDatabase$2.iniFile(IniFileConfigDatabase.java:63) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.fs.INIFile.checkReload(INIFile.java:330) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.fs.INIFile.get(INIFile.java:56) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.fs.IniFileConfigDatabase.getGlobal(IniFileConfigDatabase.java:100) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.bdbje.JEObjectDatabase.newTransaction(JEObjectDatabase.java:878) ~[geogig-bdbje-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.bdbje.JEObjectDatabase.putInternal(JEObjectDatabase.java:630) ~[geogig-bdbje-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.AbstractObjectStore.put(AbstractObjectStore.java:224) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.ForwardingObjectDatabase.put(ForwardingObjectDatabase.java:127) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.di.ObjectDatabasePutInterceptor$GraphUpdatingObjectDatabase.put(ObjectDatabasePutInterceptor.java:65) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.storage.ForwardingObjectDatabase.put(ForwardingObjectDatabase.java:127) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.api.porcelain.InitOp.callInternal(InitOp.java:216) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.api.porcelain.InitOp._call(InitOp.java:125) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.api.porcelain.InitOp._call(InitOp.java:64) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.api.AbstractGeoGigOp.call(AbstractGeoGigOp.java:133) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.cli.porcelain.Init.runInternal(Init.java:99) ~[geogig-cli-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.cli.AbstractCommand.run(AbstractCommand.java:68) ~[geogig-cli-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.cli.GeogigCLI.executeInternal(GeogigCLI.java:543) [geogig-cli-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.cli.GeogigCLI.execute(GeogigCLI.java:385) [geogig-cli-1.0-RC1a.jar:1.0-RC1a]
    at org.locationtech.geogig.cli.GeogigCLI.main(GeogigCLI.java:340) [geogig-cli-1.0-RC1a.jar:1.0-RC1a]
Caused by: java.io.IOException: Permission denied
    at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.8.0_74]
    at java.io.File.createNewFile(File.java:1012) ~[na:1.8.0_74]
    at org.locationtech.geogig.storage.fs.IniFileConfigDatabase$2.iniFile(IniFileConfigDatabase.java:61) ~[geogig-core-1.0-RC1a.jar:1.0-RC1a]
    ... 18 common frames omitted
An unhandled error occurred: java.io.IOException: Permission denied. See the log for more details.

有人有想法吗? 感谢

2 个答案:

答案 0 :(得分:0)

GeoGig正在尝试读取或写入用户PHP正在运行的文件,因为它没有读取或写入权限。我建议您按照错误消息说明并“查看日志以获取更多详细信息。”找出那个文件是什么。

答案 1 :(得分:0)

我通过使用命令行sudo visudo添加visudo解决了这个问题: secure_path="......:/opt/geogig/bin" 并在文件的末尾: www-data ALL=NOPASSWD: ALL

在shell_exec中,我添加了" sudo geogig init"

我希望这有助于任何面临同样问题的人。

谢谢Chris