【问题标题】:Php file works on server but not when deployedphp文件在服务器上有效,但在部署时无效
【发布时间】:2019-05-13 10:50:59
【问题描述】:

我有要为网站运行的 PHP 脚本,但它在部署中不起作用。 当使用 (php filename.php) 运行文件时在 shell 上显示正确的输出,但在使用 htttp:example.com/filename.php 通过网页调用时不起作用

我可以在错误日志中看到这一点

[cgi:error] [pid 19938] [client 132.186.22.181:55166] AH01215: (13)Permission denied: exec of '/var/www/cgi-bin/infophp.php' failed

网页显示

内部服务器错误

服务器遇到内部错误或 配置错误,无法完成您的请求。

请通过root@localhost联系服务器管理员告知 他们发生此错误的时间以及您执行的操作 就在这个错误之前。

有关此错误的更多信息可能在服务器错误中可用 记录。

我都试过了,但都报同样的错误。

<?php 
echo "hello world";
?>

<?php
phpinfo();
?>

我应该能够在调用时看到执行的脚本 http://example.com/file.php

【问题讨论】:

  • 您似乎没有在特定文件夹位置部署文件的权限
  • 看起来更像是操作系统问题(用户和权限问题)而不是 PHP 脚本问题。如果您有Linux 环境,请尝试检查您的用户是否属于www-data,或者您是否将www-data 用户归因于您的项目文件夹
  • /var/www/cgi-bin/infophp.php 是你的文件吗?

标签: php linux server apache2


【解决方案1】:

部署后请检查文件的权限

  1. 用户无权从公共访问
  2. 该文件可能是只读的

    chmod 644

    或 chmod -R 777 {最坏情况}

【讨论】:

    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2023-02-24
    • 1970-01-01
    • 2018-04-02
    • 2020-07-02
    • 1970-01-01
    • 2013-01-25
    相关资源
    最近更新 更多