# PHP extensions.ini order



## Mayhem30 (Feb 2, 2016)

Does anyone know where/how to figure out the proper extension.ini order?

I've been having issues lately with new forum software I installed and I believe it's related to PHP extensions order.

I've just started using this : https://people.freebsd.org/~ohauer/scripts/fixphpextorder.sh

It's too early to tell if its' going to fix the issue or not (couldn't hurt to try) , but after I ran the script, there was 3 extensions it did not know where to order it in the list :


```
extension=session.so
extension=fileinfo.so
extension=simplexml.so
extension=dba.so
extension=ctype.so
extension=apc.so
extension=ftp.so
extension=mbstring.so
extension=tokenizer.so
extension=filter.so
extension=mcrypt.so
extension=xmlwriter.so
extension=gd.so
extension=iconv.so
extension=calendar.so
extension=exif.so
extension=zlib.so
extension=curl.so
extension=xmlrpc.so
extension=bz2.so
extension=openssl.so
extension=dom.so
extension=hash.so
extension=xmlreader.so
extension=bcmath.so
extension=pdo.so
extension=pdo_mysql.so
extension=mysqli.so
extension=mysql.so
extension=imap.so
extension=pspell.so
extension=xml.so
; additional extension(s) not known by fixphpextorder.sh
extension=json.so
extension=posix.so
extension=zip.so
```

Anyone know offhand where to place json, posix and zip in the list?


----------



## SirDice (Feb 2, 2016)

I don't think I have ever needed to change the order in extension.ini. What exactly are the problems you're having?


----------



## Mayhem30 (Feb 2, 2016)

SirDice said:


> I don't think I have ever needed to change the order in extension.ini. What exactly are the problems you're having?



I'm using Nginx and proxy all PHP requests to Apache for processing.

When the new forum software attempts to do a JSON request to validate an email address (which is sent to Apache), I immediately receive a "503 Bad Gateway" error.

The Nginx error log shows :

```
2016/02/01 19:02:04 [error] 41812#0: *53327 upstream prematurely closed connection while reading response header from upstream, client: xx.xx.xx.xx, server: example.com, request: "POST /account/validate-field.json HTTP/1.1", upstream: "http://127.0.0.1:80/account/validate-field.json"
```
Nothing shows up in the Apache error log. However, the "messages" log shows this :

```
Feb  1 19:02:04 localhost kernel: pid 52821 (httpd), uid 80: exited on signal 10
```
So not only is the JSON request failing (503 Bad Gateway), it's also killing the Apache process that was attempting to handle it. I just would like to mention that I have been using the same extensions.ini order for almost 10 years now without any issues on my websites.

However, changing the extensions order last night (using the script) so far, has fixed this issue. I am using the same forum software as this site (XenForo).


----------



## gkontos (Feb 2, 2016)

It is a problem that I have faced for ages. What I do to bypass it is to `cp [FILE]extensions.ini[/FILE] [FILE]extensions.ini.bak[/FILE]` before upgrading php and them roll back the file.


----------



## Mayhem30 (Feb 2, 2016)

gkontos said:


> It is a problem that I have faced for ages. What I do to bypass it is to `cp [FILE]extensions.ini[/FILE] [FILE]extensions.ini.bak[/FILE]` before upgrading php and them roll back the file.


That's what I have been doing as well, however I was forced to change the order I have been using for almost 10 years after installing Xenforo.


----------



## frijsdijk (Aug 4, 2016)

Well lookie here!

https://svnweb.freebsd.org/ports?view=revision&revision=419514


----------



## Mayhem30 (Aug 4, 2016)

I upgraded to the new version last night and everything is running smoothly. It's nice not to have to worry about this anymore.


----------



## frijsdijk (Aug 4, 2016)

Well, not for me ..  I have the following extensions (lang/php70):


```
ext-10-opcache.ini
ext-20-bcmath.ini
ext-20-bz2.ini
ext-20-calendar.ini
ext-20-ctype.ini
ext-20-curl.ini
ext-20-dom.ini
ext-20-exif.ini
ext-20-fileinfo.ini
ext-20-filter.ini
ext-20-ftp.ini
ext-20-gd.ini
ext-20-hash.ini
ext-20-iconv.ini
ext-20-imagick.ini
ext-20-imap.ini
ext-20-intl.ini
ext-20-json.ini
ext-20-ldap.ini
ext-20-mbstring.ini
ext-20-mcrypt.ini
ext-20-mysqli.ini
ext-20-openssl.ini
ext-20-pdo.ini
ext-20-posix.ini
ext-20-readline.ini
ext-20-recode.ini
ext-20-session.ini
ext-20-simplexml.ini
ext-20-smbclient.ini
ext-20-sockets.ini
ext-20-sqlite3.ini
ext-20-tokenizer.ini
ext-20-xml.ini
ext-20-xmlwriter.ini
ext-20-zip.ini
ext-20-zlib.ini
ext-30-pdo_mysql.ini
ext-30-pdo_sqlite.ini
ext-30-phar.ini
ext-30-pspell.ini
ext-30-redis.ini
ext-30-soap.ini
ext-30-wddx.ini
ext-30-xmlreader.ini
ext-30-xmlrpc.ini
ext-30-xsl.ini
```

.. but it coredumps. Where could I report this?

I ended up generating my own .ini files with my own order from my previous extensions.ini


----------



## Mayhem30 (Aug 4, 2016)

Why are you using lang/php70? It's barely even in beta (and states not to use it in a production environment).


----------



## frijsdijk (Aug 4, 2016)

Is it? It works pretty well actually! If nobody would use it, it would never come out of beta. Anyway, this concerns a private server, low traffic, just a couple of sites, nothing special.

Curious: where is it mentioned that it's beta?

PS: you should try it too, it's blazing fast!


----------



## Mayhem30 (Aug 4, 2016)

I would try it, but I have too many sites generating good income and can't afford downtime or for things to be going wrong. I'm currently running lang/php56 without issues.

If you check out php.net, all I see is beta and alpha's listed.


----------



## frijsdijk (Aug 4, 2016)

As I see it, 7.0.9 is pretty much production-ripe (Ubuntu 16.04 ships with 7.0.8), and by the looks of it, 7.1.x is beta.


----------



## Sampsa Suoninen (Oct 20, 2016)

Rule of thumb I have used, as the new system is just as bad as the previous ones, just made it harder to maintain.

Always load these first: readline, recode, simplexml and session. You can do this by moving or copying the file to one with lower number. My example below (session was automatically loaded before most, just happens to work):

ext-08-readline.ini
ext-08-recode.ini
ext-08-simplexml.ini
ext-10-opcache.ini
ext-18-session.ini
ext-20-bcmath.ini


----------



## frijsdijk (Oct 20, 2016)

FWIW.. in PHP7 (FPM config), I've made my own 'order' which works nicely:


```
ext-001-zlib.so.ini
ext-002-zip.so.ini
ext-003-bcmath.so.ini
ext-004-bz2.so.ini
ext-005-calendar.so.ini
ext-006-ctype.so.ini
ext-007-mysqli.so.ini
ext-008-openssl.so.ini
ext-009-mcrypt.so.ini
ext-010-pdo.so.ini
ext-011-pdo_mysql.so.ini
ext-012-mbstring.so.ini
ext-013-filter.so.ini
ext-014-pdo_sqlite.so.ini
ext-015-posix.so.ini
ext-016-readline.so.ini
ext-017-recode.so.ini
ext-018-hash.so.ini
ext-019-session.so.ini
ext-020-pspell.so.ini
ext-021-redis.so.ini
ext-022-phar.so.ini
ext-023-fileinfo.so.ini
ext-024-iconv.so.ini
ext-025-sqlite3.so.ini
ext-026-tokenizer.so.ini
ext-027-sockets.so.ini
ext-028-ldap.so.ini
ext-029-simplexml.so.ini
ext-030-soap.so.ini
ext-031-json.so.ini
ext-032-curl.so.ini
ext-033-exif.so.ini
ext-034-xml.so.ini
ext-035-xmlwriter.so.ini
ext-036-xmlrpc.so.ini
ext-037-wddx.so.ini
ext-038-imap.so.ini
ext-039-dom.so.ini
ext-040-ftp.so.ini
ext-041-xsl.so.ini
ext-042-xmlreader.so.ini
ext-043-gd.so.ini
ext-044-imagick.so.ini
ext-045-opcache.so.ini
ext-046-intl.so.ini
ext-047-memcache.so.ini
```


----------

