phpStorm 问题与 php-cgi
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24239128/
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
phpStorm problems with php-cgi
提问by Steve
So I recently change to ubuntu and I am trying to setup my environment again and I manage to install LAMP and phpmyadmin and phpstorm.
所以我最近改用 ubuntu,我试图再次设置我的环境,我设法安装了 LAMP、phpmyadmin 和 phpstorm。
But what I can't mange to do is to run the php script from phpStorm when I try to run the program the page gives me a "502 Bad gateway" error and when I go back on phpStorm it tells me that php-cgi was not found.
但是我无法做的是当我尝试运行该程序时从 phpStorm 运行 php 脚本,该页面给我一个“502 Bad gateway”错误,当我回到 phpStorm 时,它告诉我 php-cgi 是未找到。
I have tried to fix the problem but couldn't find any solid answer and I am so confused right now
我试图解决这个问题,但找不到任何可靠的答案,我现在很困惑
Also I have successfully added the php interpreter and the xDebug
我也成功添加了 php 解释器和 xDebug
回答by IWS
on linux ubuntu
在 linux ubuntu 上
For PHP5: sudo apt-get install php5-cgi
对于 PHP5: sudo apt-get install php5-cgi
For PHP7: sudo apt-get install php7.0-cgi
对于 PHP7: sudo apt-get install php7.0-cgi
回答by vbarbarosh
I faced with the same problem. After replacing /usr/bin/php5-cgi with a little shell script I found that error
我遇到了同样的问题。用一个小 shell 脚本替换 /usr/bin/php5-cgi 后,我发现了这个错误
Host 'localhost' has multiple addresses. You must choose one explicitly! Couldn't create FastCGI listen socket on port localhost:56468
主机 'localhost' 有多个地址。您必须明确选择一个!无法在端口 localhost:56468 上创建 FastCGI 侦听套接字
After commenting After commenting IPv6 hosts the problem seems to be solved:127.0.0.1 localhost
in /etc/hosts the problem seems to be solved.
评论 IPv6 主机后,问题似乎已解决:127.0.0.1 localhost
在 /etc/hosts 中评论后,问题似乎解决了。
# The following lines are desirable for IPv6 capable hosts
# ::1 localhost ip6-localhost ip6-loopback
# ff02::1 ip6-allnodes
# ff02::2 ip6-allrouters
回答by Denys
for mac:
对于 Mac:
install XAMPP (it's easy and straight forvard) it comes with apache and php interpreter
in phpstorm in settings ->php -> interpreter choose path /Applications/XAMPP/bin/php
phpstorm in settings -> build, ... -> Deployment add in place server, url root localhost
安装 XAMPP(它简单直接)它带有 apache 和 php 解释器
在 phpstorm 中设置 ->php -> 解释器选择路径 /Applications/XAMPP/bin/php
设置中的 phpstorm -> build, ... -> Deployment add in place server, url root localhost
More info can be found on jetbrainsweb page
更多信息可以在jetbrains网页上找到
This helped me to solve this problem and run php by clicking on web browser icon inside phpstorm.
这帮助我解决了这个问题,并通过单击 phpstorm 中的 Web 浏览器图标来运行 php。
and don't forget to turn on apache in xampp --> manage servers!)
并且不要忘记在 xampp 中打开 apache --> 管理服务器!)
回答by Tanmay Baranwal
If it's not already done install Homebrew :
如果尚未完成安装 Homebrew :
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Now, that we've Homebrew, tap php repositories by entering this on your terminal :
现在,我们有了 Homebrew,通过在终端上输入以下内容来点击 php 存储库:
brew tap josegonzalez/php
brew tap homebrew/dupes
Check what options are available for PHP 5.4 :
检查 PHP 5.4 可用的选项:
brew options php54
Now install/build PHP 5.4 with some option (in your case PHP-FPM with CGI) :
现在使用一些选项安装/构建 PHP 5.4(在您的情况下使用 CGI 的 PHP-FPM):
brew install php54 --with-fpm --with-debug --with-cgi --with-libmysql --with-homebrew-curl
brew install fastcgi
Note : If you're not going to use Apache add --without-apache, if you need others things, just check the options and add what you need
注意:如果您不打算使用 Apache add --without-apache,如果您需要其他东西,只需检查选项并添加您需要的东西
Now, check if PHP-FPM is enable by typing this in your terminal :
现在,通过在终端中键入以下内容来检查是否启用了 PHP-FPM:
php-fpm -v
If you get this :
如果你得到这个:
PHP 5.4.24 (fpm-fcgi) Copyright (c)
1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013
Zend Technologies
PHP 5.4.24 (fpm-fcgi) 版权所有 (c)
1997-2013 PHP Group Zend Engine v2.4.0,版权所有 (c) 1998-2013
禅德科技
You just installed PHP with FCGI like a boss..
你刚刚像老板一样安装了带有FCGI的PHP..
回答by user3756718
Basically the who page says to do this.
基本上 who 页面说要这样做。
Download the interpreter thing oh php from php.net.
Do make install
Make a file called newpath.txt and add to it
PATH=~/custom/php5/bin:$PATH export PATH
Type cat newpath.txt >> .profile
从 php.net 下载解释器 oh php。
做安装
创建一个名为 newpath.txt 的文件并添加到其中
PATH=~/custom/php5/bin:$PATH export PATH
输入 cat newpath.txt >> .profile
I will make a youtube video and upload it.
我会制作一个youtube视频并上传。
回答by Raphael Lehmann
In the "PHP-CGI Server" tab in phpStorm you see the error:
在 phpStorm 的“PHP-CGI 服务器”选项卡中,您会看到错误:
/usr/bin/php-cgi -e -b localhost:52109
Host 'localhost' has multiple addresses. You must choose one explicitly!
Couldn't create FastCGI listen socket on port localhost:52109
PHP-CGI Server terminated
There curently seems not to be any fix for this known bug: https://youtrack.jetbrains.com/issue/WI-24373Commenting out either the IPv4 or the IPv6 address for localhost in /etc/hosts (on Linux) is a workaround.
目前似乎没有针对此已知错误的任何修复程序:https://youtrack.jetbrains.com/issue/WI-24373 在 /etc/hosts(在 Linux 上)中注释掉 localhost 的 IPv4 或 IPv6 地址是一个解决方法。
回答by Mehdi Soltani
I also had this problem. It depends on your version of php that you want to use it as interpreter in your PhpStorm.
我也有这个问题。这取决于您想在 PhpStorm 中将其用作解释器的 php 版本。
This error message shows that PhpStorm needs to CGI binary to execute your code.
此错误消息表明 PhpStorm 需要 CGI 二进制文件才能执行您的代码。
I'm using Ubuntu 18.04 and PHP version that I have used is 7.2.
我使用的是 Ubuntu 18.04,我使用的 PHP 版本是 7.2。
You need to install modules based on your application requirements. So you use this following command to search available PHP 7 modules in the package repository:
您需要根据您的应用程序要求安装模块。因此,您可以使用以下命令在包存储库中搜索可用的 PHP 7 模块:
sudo apt-cache search php7*
Now you can see all of available modules (also for cgi) in repository. Now You must install the required PHP modules on your system as below command. Make sure to install packages for correct PHP version by specifying the version with the package name. Without defining the package version, it will install the latest package. E.g. for me, I need php7.2-cgi :
现在您可以在存储库中看到所有可用模块(也适用于 cgi)。现在您必须按照以下命令在系统上安装所需的 PHP 模块。通过使用包名称指定版本,确保为正确的 PHP 版本安装包。不定义包版本,它会安装最新的包。例如对我来说,我需要 php7.2-cgi :
sudo apt install php7.2-cgi
Now cgi is installed. You must restart PhpStorm and test it again. It works well for me.
现在安装了 cgi。您必须重新启动 PhpStorm 并再次测试。这对我来说很有用。