# fastcgi does not start



## Beeblebrox (Nov 22, 2012)

I use www/lighttpd for web server.
At some point the server on the host system stopped working (failed to start) if mod_fastcgi was enabled in the config files. I was OK with it because I had migrated the http + php based services into a jail and that was working without any problems.

Today however, I updated lang/php5 in the jail and now the web server is unable to start, just like in the host side:

```
(log.c.166) server started 
(mod_fastcgi.c.1103) the fastcgi-backend /usr/local/bin/php-cgi failed to start: 
(mod_fastcgi.c.1107) child exited with status 255 /usr/local/bin/php-cgi 
(mod_fastcgi.c.1110) If you're trying to run your app as a FastCGI backend,
make sure you're using the FastCGI-enabled version.
(mod_fastcgi.c.1397) [ERROR]: spawning fcgi failed. 
(server.c.964) Configuration of plugins failed. Going down.
```
I am now trying to debug from the host side (since both errors are identical) - I have lang/php5-extensions and www/spawn-fcgi installed. If I try to start fcgi manually I again get same code 255 error:
`# /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/local/bin/php-cgi`
I don't have anything defined for spawn-fcgi in /etc/rc.conf because AFAIK lighttpd's config files take care of all settings anyway.
My guess is I am missing something in the config file or I need to use apache's www/mod_fcgid? lang/php52 config settings has a separate knob for fastcgi while lang/php5 and lang/php53 do not, by the way, but php52 is marked as DEPRECATED.


----------



## ziyanm (Nov 27, 2012)

if you're using php v5.3 or later why not enable the built-in fastcgi support (php-fpm)? I don't know about spawn-fcgi but you DO have to start php-fpm at boot via the provided rc script


----------



## Beeblebrox (Nov 27, 2012)

Hi, I was thinking of switching to / trying  php5.3. Do you use it? Is it good to switch?
Regards.


----------



## ziyanm (Nov 28, 2012)

In your OP you said you installed lang/php5 which means you have php v5.4 already. So you can just do a make config and enable php-fpm and reinstall. 

I am running php 5.3 for compatibility with some older apps but use the latest version if you can since it will have the longest support lifetime.


----------



## Beeblebrox (Nov 28, 2012)

I did not realize at what version number lang/php5 was.
Config files for php5 and extensions are correct. The problem seems to be elsewhere unfortunately.


----------



## Beeblebrox (Nov 28, 2012)

I enabled DEBUG and EMBEDDED in config, re-built and reinstalled php5 (I do not have APACHE enabled).
`#  php -v`

```
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525-debug/
sockets.so' - Cannot open "/usr/local/lib/php/20100525-debug/sockets.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525-debug/
session.so' - Cannot open "/usr/local/lib/php/20100525-debug/session.so" in Unknown on line 0
Fatal error: Directive 'magic_quotes_gpc' is no longer available in PHP in Unknown on line 0
```
-i and -m flags also give the same output. I have looked through php.ini and disabled magic_quotes_gpc in the file but the error persists. Also looked through php-fpm.conf but I don't see anything that could cause a problem. I have made almost no modifications to the original content and am using it as it came.


----------



## Beeblebrox (Nov 29, 2012)

OK, folks I seem to have sorted through this quite a bit and here's how it goes:
New version php has disabled some of the features of the old version it seems. So hit`# php -i`
and at the very bottom of the error you will see something like

```
Fatal error: Directive 'magic_quotes_gpc' is no longer available in PHP in Unknown on line 0
```
Then in /usr/local/etc.php.ini, find that line and disable it. redo a # php -i and you will get a new error message about some other setting. Continue the process until you get no more error messages and the php command with -i -m -v flags no longer gives errors. You will also see the "Unable to load dynamic library" messages disappear on their own.

Now a second problem: Look in /usr/local/etc.php-fpm.conf and find this line:

```
listen = 127.0.0.1:9000
```
Make sure the fastcgi configuration in your server config files directs to same port (my old setting for lighttpd had 9999 for example)


----------

