Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Jenny Swift
Jenny Swift
21,999 Points

--enable-fastcgi

Hi, I am trying out PHPStorm and cannot open my site in my browser from PHPStorm. When I try, the page that opens says:

502 Bad Gateway

and in PHPStorm, a notification says:

php-cgi not found
Please ensure that configured PHP Interpreter built as CGI program (--enable-fastcgi was specified)

I didn’t know what this meant so I contacted PHPStorm support and they told me to navigate to the PHP installation folder and update my configuration by running --enable-fastcgi.

I suppose I should instead do --enable-cgi because according to the docs --enable-fastcgi no longer exists.

But I like to know a bit about what I’m doing before running commands in the command line, and I saw the following warning from here:

A server deployed in CGI mode is open to several possible vulnerabilities. Please read our CGI security section to learn how to defend yourself from such attacks.

This link looks overwhelming and I don't know what it's talking about, so could someone please confirm if it is safe for me to follow the instructions from support and run the command?

And what is the PHP installation folder? I am using Laravel Homestead. Would I simply ssh into the homestead directory and type --enable-cgi?

1 Answer

Kevin VanderWulp
Kevin VanderWulp
5,180 Points

I am assuming you're trying to use the built in webserver function? You probably have to have PHP installed on your local machine if you are using this feature. If you are running Linux (Ubuntu) try running sudo apt-get install php-cgi on your local machine.

Jenny Swift
Jenny Swift
21,999 Points

Hi Kevin and thank you for the reply! I tried running sudo apt-get install php-cgi from my home directory and it told me the command apt-get was not found.
So I thought I'd try running it from the homestead vagrant box (or virtual box? I get them mixed up.) and it responded with:
Reading package lists... Done Building dependency tree
Reading state information... Done E: Unable to locate package php-cgi

And so I'm still getting the same error with PHPStorm.

"I am assuming you're trying to use the built in webserver function?" Yes, apparently (that's what I was told), although I don't really know what that is. The main thing I am hoping to achieve is to try out PHPStorm's debugging functionality, and I figured if it can't open my site in the browser it's not going to be able to debug it.