I'm trying to run a simple php file with PhpStorm (v2017.3). It should output a var_dump
, but I constantly encounter a 502 bad gateway error in my browser when running the script. I receive the following error in the PhpStorm:
php-cgi not found: Please ensure that configured PHP Interpreter built as CGI program (--enable-fastcgi was specified)
When I run php -v
in my terminal here is the output:
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Here are the things I've tried so far:
brew uninstall php71
and then brew install71
.--with-cgi
option to my brew install php71
commandI had this same issue. I have the php installed but I need the CGI module. For Ubuntu users it is easy, just run this command:
sudo apt install -y php7.2-cgi
This command will install the stable version of php that is 7.2. You can install the version 7.1, 5.5, or what ever you need.
For Mac user you can install using this script:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
Check this link or read the php documentation for more information.
Homebrew typically installs the binaries in the /usr/local/bin
folder. To finalize this installation, you should tell PhpStorm which interpreter it is using. If you dont do the following step, PhpStorm will autodetect the php shipped with OSX.
Open preferences, go to Languages & Frameworks
, select PHP, and you will see the appropriate settings. For the PHP Ececutable, there is a ...
, click on it and you will see :
Just navigate to /usr/local/bin
and click on the php binary, the one from homebrew.
ps : the 'ini' files you need to edit are in /usr/local/etc/php/M.m
where M.m are major.minor version of the installed php (7.1 in your case).
These are the steps to solve this common issue:
Setup Brew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update Brew: brew update
Add repo: brew tap homebrew/php
Install PHP: brew install php
Preferences
menu follow the Languages & Frameworks
and then go to PHP
section ...
button next to CLI Interpreter
setting+
and then choose Other Local...
, enter this address /usr/local/bin/php
to the PHP executable:
section in menuI got the same error using PHPStorm with MAMP, so in this case I configure the PHPStorm to using php-cgi installed by MAMP.
For this in PHPStorm, open Preferences
—> Languages
—> PHP
and configure like that:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With