# PHP-FPM not starting after updates



## Anon (Oct 28, 2012)

```
# /usr/local/etc/rc.d/php-fpm restart
php_fpm not running? (check /var/run/php-fpm.pid).
Starting php_fpm.
/libexec/ld-elf.so.1: Shared object "libpcre.so.0" not found, required by "php-fpm"
/usr/local/etc/rc.d/php-fpm: WARNING: failed to start php_fpm
```

Any advice guys, please?


----------



## Anon (Oct 28, 2012)

I just did the following.


```
ln -s /usr/local/lib/libpcre.so.1 /usr/local/lib/libpcre.so.0
```

Now I'm getting back the following error:


```
# /usr/local/etc/rc.d/php-fpm restart
php_fpm not running? (check /var/run/php-fpm.pid).
Starting php_fpm.
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/gd.so' - Shared object "libpng.so.6" not found, required by "gd.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/gd.so' - Shared object "libpng.so.6" not found, required by "gd.so" in <b>Unknown</b> on line <b>0</b>

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/pdf.so' - Shared object "libpdf.so.8" not found, required by "pdf.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/pdf.so' - Shared object "libpdf.so.8" not found, required by "pdf.so" in <b>Unknown</b> on line <b>0</b>
```


----------



## Anon (Oct 28, 2012)

I wonder if there's any way to revert the updates from portmanager -u? I hope there is, if there isn't I've made a grave mistake.


----------



## Anon (Oct 28, 2012)

The reason this is bothering me is because I'm getting 502 errors whenever I try to upload/post something on my site after running the updates and rebooting.


----------



## Anon (Oct 28, 2012)

Just looked at my NGINX log, I found the following:


```
2012/10/28 03:57:20 [error] 958#0: *160 upstream prematurely closed connection while reading response header from upstream, client: **.**.**.**, server: ..., request: "POST /post.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php.sock:", host: "...", referrer: "..."
```


----------



## Anon (Oct 28, 2012)

I don't get it... I looked at the PHP-FPM and NGINX config files and they aren't changed at all from before and post update. I do not understand why post-updates now I'm having these errors.


----------



## Anon (Oct 28, 2012)

Stupid question, but is it possible the socket isn't started? How do I restart the socket?


```
upstream: "fastcgi://unix:/tmp/php.sock:",
```


----------



## Anon (Oct 28, 2012)

Going to bed now I can't stay up any longer, this problem is killing me. Please if anyone can help, if anyone has even the slightest advice, please give it. Thanks in advance.


----------



## AlexJ (Oct 28, 2012)

There is a good tools sysutils/bsdadminscripts that will install *plg_libchk* which can help to find all packages requiring libpcre.so.0. Anything that it find need to be recompiled.

P.S.
I hope that you know that you MUST read /usr/ports/UPDATING *BEFORE* any upgrade. Usually it is a case, sometimes not...


----------



## Anon (Oct 28, 2012)

AlexJ said:
			
		

> There is a good tools sysutils/bsdadminscripts that will install *plg_libchk* which can help to find all packages requiring libpcre.so.0. Anything that it find need to be recompiled.
> 
> P.S.
> I hope that you know that you MUST read /usr/ports/UPDATING *BEFORE* any upgrade. Usually it is a case, sometimes not...



I can't sleep, this problem is killing me. I already fixed the libpcre.so.0 issue, now I just want to fix the 502's due to the "upstream prematurely closed connection while reading response header from upstream" error. If you have any ideas or suggestions please tell me.

Please help, any ideas are welcome, I'm willing to try anything at this point.


----------



## Anon (Oct 28, 2012)

portsnap fetch extract
portmanager -u

That's what I did... that's what began this whole ordeal. What a grave mistake it was...


----------



## Anon (Oct 28, 2012)

Okay WTF I just noticed that the front page of my site has been changed to the "Welcome to nginx!" thing, huh?


----------



## AlexJ (Oct 28, 2012)

portsnap fetch extract
should followed by
portsnap fetch update

Looks like Nginx can't connect to php-fpm
Did you try to connect directly to php
[CMD=""]#telnet localhost 9000[/CMD]


----------



## Anon (Oct 28, 2012)

AlexJ said:
			
		

> portsnap fetch extract
> should followed by
> portsnap fetch update
> 
> ...



Thanks for the reply, AlexJ, I don't know how to connect directly to PHP, I am still a newbie to FreeBSD. I'll remember that about portsnap.


```
# telnet localhost 9000
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: connect to address ::1: Connection refused
telnet: Unable to connect to remote host
```


----------



## AlexJ (Oct 28, 2012)

Anon said:
			
		

> I'll remember that about portsnap.



You need portsnap fetch extract only once, all subsequent calls should be portsnap fetch update.

As about php, check it fist if it works after upgrade
[CMD=""]php -r 'echo "Test\n";'[/CMD]
sometimes even order of extensions could issue segmentation fault

If it's works, step further, locate in php-fpm.conf _listen_ option and 
check if it is 
[CMD=""]listen = 127.0.0.1:9000[/CMD]
if not, change it temporally and restrat php-fpm
[CMD=""]/usr/local/etc/rc.d/php-fpm restart[/CMD]

and try to connect to php again 
[CMD=""]telnet 127.0.0.1:9000[/CMD]

Nginx obviously can't talk to php that why it return 502.


----------



## Anon (Oct 28, 2012)

AlexJ said:
			
		

> You need portsnap fetch extract only once, all subsequent calls should be portsnap fetch update.
> 
> As about php, check it fist if it works after upgrade
> [CMD=""]php -r 'echo "Test\n";'[/CMD]
> ...



Thanks again for the help, I'm losing my mind over this and I appreciate the help.


```
#  php -r 'echo "Test\n";'
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/gd.so' - Shared object "libpng.so.6" not found, required by "gd.so" in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/gd.so' - Shared object "libpng.so.6" not found, required by "gd.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/pdf.so' - Shared object "libpdf.so.8" not found, required by "pdf.so" in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/pdf.so' - Shared object "libpdf.so.8" not found, required by "pdf.so" in Unknown on line 0
Test
```

After changing the listen socket temporarily I now get back:

```
# telnet 127.0.0.1:9000
127.0.0.1:9000: hostname nor servname provided, or not known
```


----------



## Anon (Oct 28, 2012)

Also


```
# telnet localhost 9000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
```


----------



## Anon (Oct 28, 2012)

Guys, if this was your server and you needed to get it back and running, what would you do? Please help.


----------



## wblock@ (Oct 28, 2012)

Anon said:
			
		

> I just did the following.
> 
> 
> ```
> ...



Sweeping it under the rug is not a cure.  Remove the link and rebuild any software that depends on the old pcre.  pkg_libchk(1), as already mentioned, will detect those.



> ```
> # /usr/local/etc/rc.d/php-fpm restart
> php_fpm not running? (check /var/run/php-fpm.pid).
> Starting php_fpm.
> ...



So libpng from graphics/png has also been updated incorrectly.  As above, anything that depends on libpng must be rebuilt.  Both ports-mgmt/portupgrade[-devel] and ports-mgmt/portmaster can do that.


----------



## wblock@ (Oct 28, 2012)

Restore from backup.  Actually, I'd only do that if it was an extreme emergency.  Otherwise, install portmaster or portupgrade and rebuild everything that depends on pcre or png.
`# portupgrade -rf pcre png`
or
`# portmaster -r pcre png`


----------



## Anon (Oct 28, 2012)

I reinstalled PHP5 and am now getting this back:


```
# /usr/local/etc/rc.d/php-fpm restart
Stopping php_fpm.
Waiting for PIDS: 47704.
Starting php_fpm.
[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/calendar.so' - Cannot open "/usr/local/lib/php/20100525/calendar.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/calendar.so' - Cannot open "/usr/local/lib/php/20100525/calendar.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/ctype.so' - Cannot open "/usr/local/lib/php/20100525/ctype.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/ctype.so' - Cannot open "/usr/local/lib/php/20100525/ctype.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/dom.so' - Cannot open "/usr/local/lib/php/20100525/dom.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/dom.so' - Cannot open "/usr/local/lib/php/20100525/dom.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/exif.so' - Cannot open "/usr/local/lib/php/20100525/exif.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/exif.so' - Cannot open "/usr/local/lib/php/20100525/exif.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/fileinfo.so' - Cannot open "/usr/local/lib/php/20100525/fileinfo.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/fileinfo.so' - Cannot open "/usr/local/lib/php/20100525/fileinfo.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/filter.so' - Cannot open "/usr/local/lib/php/20100525/filter.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/filter.so' - Cannot open "/usr/local/lib/php/20100525/filter.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/gd.so' - Cannot open "/usr/local/lib/php/20100525/gd.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/gd.so' - Cannot open "/usr/local/lib/php/20100525/gd.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/gettext.so' - Cannot open "/usr/local/lib/php/20100525/gettext.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/gettext.so' - Cannot open "/usr/local/lib/php/20100525/gettext.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/hash.so' - Cannot open "/usr/local/lib/php/20100525/hash.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/hash.so' - Cannot open "/usr/local/lib/php/20100525/hash.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/iconv.so' - Cannot open "/usr/local/lib/php/20100525/iconv.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/iconv.so' - Cannot open "/usr/local/lib/php/20100525/iconv.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/json.so' - Cannot open "/usr/local/lib/php/20100525/json.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/json.so' - Cannot open "/usr/local/lib/php/20100525/json.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mbstring.so' - Cannot open "/usr/local/lib/php/20100525/mbstring.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mbstring.so' - Cannot open "/usr/local/lib/php/20100525/mbstring.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mcrypt.so' - Cannot open "/usr/local/lib/php/20100525/mcrypt.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mcrypt.so' - Cannot open "/usr/local/lib/php/20100525/mcrypt.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mysql.so' - Cannot open "/usr/local/lib/php/20100525/mysql.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mysql.so' - Cannot open "/usr/local/lib/php/20100525/mysql.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mysqli.so' - Cannot open "/usr/local/lib/php/20100525/mysqli.so" in Unknown on line 0


<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/mysqli.so' - Cannot open "/usr/local/lib/php/20100525/mysqli.so" in <b>Unknown</b> on line <b>0</b>

[28-Oct-2012 14:19:28] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20100525/pdo.so' - Cannot open "/usr/local/lib/php/20100525/pdo.so" in Unknown on line 0
etc....
```


----------



## Anon (Oct 28, 2012)

Hmmm, interesting. It seems as if the paths have moved.


```
<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/[b]20100525[/b]/calendar.so' - Cannot open "/usr/local/lib/php/20100525/calendar.so" in <b>Unknown</b> on line <b>0</b>
```


```
# locate calendar.so
/usr/lib/libcalendar.so
/usr/lib/libcalendar.so.5
/usr/local/lib/php/[b]20090626[/b]/calendar.so
/usr/share/calendar/calendar.southafrica
```

Is there a way to update paths?


----------



## Anon (Oct 28, 2012)

Hmmm!


```
# locate mbstring.so
/usr/local/lib/php/20090626/mbstring.so
```

It looks like all the new PHP extensions have moved over to *20090626*. Is there a way I can make PHP look for /usr/local/lib/php/20090626/ instead of /usr/local/lib/php/20100525/? That would fix this issue.


----------



## PugTsurani (Oct 28, 2012)

What version FreeBSD are you running?
[cmd=""]uname -a[/cmd]

What PHP extensions do you have installed?
[cmd=""]pkg_info -Ix php[/cmd]

I frequently refer to this page when updating ports because it's short and to the point. I use ports-mgmt/portupgrade, not ports-mgmt/portmanager, so I don't know if *pkgdb -F* and *portsdb -Uu* will help.

I'm running the latest ports and all PHP extensions are in *20100525*, not *20090626*. This implies PHP is was upgraded but not the extensions. Rather than trying to downgrade PHP to use *20090626*, I suggest upgrading all PHP extensions and their dependencies as wblock@ suggested.


----------



## Anon (Oct 28, 2012)

Yes! Everything seems to be working now, only one slight error that isn't letting me post:


```
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /usr/local/www/nginx-dist/func.php on line 67
```


----------



## wblock@ (Oct 28, 2012)

PugTsurani said:
			
		

> I frequently refer to this page when updating ports because it's short and to the point.



It does not mention the #1 thing to do first, which is check /usr/ports/UPDATING.  Skipping that ultra-important step will lead to problems like OP experienced, because some things like pcre and png need a special update.


----------



## Anon (Oct 28, 2012)

Issues solved by portupgrade, thanks wblock.


----------

