【问题标题】:Troubles with PhpStorm web server debug validationPhpStorm Web 服务器调试验证的问题
【发布时间】:2019-05-08 04:27:44
【问题描述】:

在 PhpStorm 中,我尝试在远程服务器上调试代码。 Web 服务器调试验证不断告诉我指定的 url 不可访问 (404)。

我的主机在windows下

我的服务器在 VirtualBox VM (Debian 9) 上

我使用 PhpStorm 在网络驱动器 V: 上编辑代码,指向我的 VM 的 /var/www/ 文件夹。这不是 VirtualBox 共享文件夹(Debian 9 不支持)。 所以,当我在 V:\myproject 上工作时,我实际上是在通过 smb 在 VM 上工作 /var/www/myproject

我遵循了很多教程,但从未成功。目前,我有以下配置:

  • PHP Cli 远程解释器,使用部署配置
  • 所述部署配置的连接类型是SFTP(连接测试OK)。根路径是/var/www/myproject。网络服务器 url 是 https://my.project.local(url 在我的浏览器中测试过)
  • 映射本地路径:V:\myproject
  • 映射部署路径:/
  • 映射网络路径:/pub(此项目是 Magento 2 应用程序。Pub 是网络根目录)

当我尝试验证Web服务器调试时,我选择“远程Web服务器”,创建验证脚本的路径是V:\myproject\pub,部署服务器是前面描述的部署配置。

验证失败,提示“无法访问指定的 URL,原因是:'Request failed with status code 404'”。

有没有人已经通过这个特定的设置? (PhpStorm + VirtualBox VM + SFTP 连接上的远程调试)。你设法让它工作吗? 也许我应该尝试另一种方法让它工作?非常感谢您的帮助!

【问题讨论】:

    标签: virtualbox magento2 xdebug remote-debugging phpstorm-2018.2


    【解决方案1】:

    有点晚了,但是对于碰巧在 Nginx 上运行 Magento 2 的其他人,请查看 nginx.conf.sample 或您正在使用的任何 ngxin.conf。

    找到下面的块:

    # PHP entry point for main application
    location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
        try_files $uri =404;
        fastcgi_pass   fastcgi_backend;
        fastcgi_buffers 1024 4k;
    
        fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
        fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
        fastcgi_read_timeout 600s;
        fastcgi_connect_timeout 600s;
    
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    

    修改它,允许 Nginx 提供验证脚本:

    # PHP entry point for main application
    location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check|_intellij_phpdebug_validator)\.php$ {
        try_files $uri =404;
        fastcgi_pass   fastcgi_backend;
        fastcgi_buffers 1024 4k;
    
        fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
        fastcgi_param  PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
        fastcgi_read_timeout 600s;
        fastcgi_connect_timeout 600s;
    
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    

    【讨论】:

    • 这行得通。万一进行这些更改后它不起作用。检查您为“创建验证脚本的路径”使用的路径:这应该指向 $MAGE_ROOT/pub,如果是 mac,它应该是 /usr/local/var/www/pub。 (假设您的 magento 安装在 /usr/local/var/www 中)。在 ubuntu 的情况下,它应该是 /var/www/html/pub。
    猜你喜欢
    • 2011-03-19
    • 2012-02-28
    • 2013-12-22
    • 2021-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-01
    • 2012-02-12
    相关资源
    最近更新 更多