Compile Centos 5.7 64bit with php5.3.8-fpm

Centos 64bit with php5.3.8-fpm:

yum groupinstall "Development Tools"
yum groupinstall "Development Libraries"
yum install mysql-devel libidn-devel zlib zlib-devel libc-client-devel mcrypt libmcrypt libmcrypt-devel.x86_64 libtool-ltdl-devel.x86_64

./configure --prefix=/usr/local/php5.3 \
--enable-fpm \
--with-mcrypt \
--enable-mbstring \
--with-curl \
--disable-debug \
--enable-inline-optimization \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-mbregex \
--with-mcrypt \
--enable-zip \
--with-bz2 \
--with-pcre-regex \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/etc/php5.3/nginx/ \
--with-config-file-scan-dir=/etc/php5.3/nginx/conf.d \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-freetype-dir=/usr/local/lib \
--enable-gd-native-ttf \
--with-imap \
--with-imap-ssl \
--with-openssl \
--with-iconv \
--with-iconv-dir=/usr/local/lib \
--with-libdir=lib64 \
--with-zlib-dir=/usr/include \
--with-kerberos=/usr \
--enable-soap

sudo strip /usr/local/sbin/nginx
sudo ln -s /usr/local/nginx/conf/ /etc/nginx
sudo mkdir /etc/nginx/sites-available /etc/nginx/sites-enabled
sudo -i
echo "include /etc/nginx/sites-enabled/*;" >> /etc/nginx/nginx.conf
exit

Some of the libraries have funky paths and don’t seem to deal well with having lib (for i386) and lib64 (for x64) on the same machine. I used these commands to get through a bunch of compilation errors (open config.log and review the last few lines for info on what has actually gone wrong. For instance

/usr/bin/ld: skipping incompatible /usr/lib/libidn.so when searching for -lidn
/usr/bin/ld: skipping incompatible /usr/lib/libidn.a when searching for -lidn

meant i hadnt compiled curl with ssl so adding libidn-devel to the install command (above) sorted that out. There are some instructions here for dealing with lib64 libs which are worth a look if you are stuck.

ZLIB extension requires zlib >= 1.0.9 php 5.3
install zlib & zlib-devel

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
install libc-client-devel
centos configure: error: mcrypt.h not found. Please reinstall libmcrypt.

install libmcrypt with the correct arch parameters (which were new to me at this point, so may be worth revisiting the whole of this article appending the .x86_64 suffix e.g. sudo yum install libmcrypt-devel.x86_64 (this is included in the yum command at the start, no need to re run)

when running make you may encounter an error like this:

/usr/bin/ld: cannot find -lltdl

this is resolved by installing the libtool-ltdl-devel package (already in the install line above)

Would seem to indicate a version mismatch or parsing error (esp when the zlib.h file is in fact the correct version...sigh) when in fact installing the correct ssl aware versions of software, together with specifying the correct directories for all involved worked out just fine.

$ ln -sf /lib64/libcom_err.so.2 /usr/lib/libcom_err.so

$ ./configure --prefix=/usr/local/php5.3 --enable-fpm --with-mcrypt --enable-mbstring --with-curl --disable-debug --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-mbregex --with-mcrypt --enable-zip --with-pcre-regex --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysql_nd --with-config-file-path=/etc/php5.3/nginx/ --with-config-file-scan-dir=/etc/php5.3/nginx/conf.d --with-gd --with-jpeg-dir=/usr/local/lib --with-freetype-dir=/usr/local/lib --enable-gd-native-ttf --with-imap --with-imap-ssl --with-kerberos --with-openssl
$ make
$ sudo make install

Your php5.3 is now installed in /usr/local/php5.3. Next copy the default settings file:

$ cd /usr/local/php5.3/etc/
$ sudo cp php-fpm.conf.default php-fpm.conf
$ sudo vi php-fpm.conf

if the nginx instance is on the same machine, then no need for the tcp overhead for fcgi connections so use a tmp socket or other:

listen = /tmp/php5.3.socket

and uncomment the default settings for:

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 50

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 20

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 5

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 35

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500

the following changes enable the status page and ping and pong page (useful for load balancing). These should probably be limited to ip address at least but are initially useful for testing.

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
;   accepted conn        - the number of request accepted by the pool;
;   pool                 - the name of the pool;
;   process manager      - static or dynamic;
;   idle processes       - the number of idle processes;
;   active processes     - the number of active processes;
;   total processes      - the number of idle + active processes.
;   max children reached - number of times, the process limit has been reached,
;                          when pm tries to start more children (works only for
;                          pm 'dynamic')
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
;   accepted conn:        12073
;   pool:                 www

;   process manager:      static
;   idle processes:       35
;   active processes:     65
;   total processes:      100
;   max children reached: 1
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' as a query string will return the corresponding output
; syntax. Example:
;   http://www.foo.bar/status
;
   http://www.foo.bar/status?json
;
   http://www.foo.bar/status?html
;
   http://www.foo.bar/status?xml
;
Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
ping.response = pong

Nginx config
Uploads by default are limited to 1Mb and Drupal silently discards this. make these changes to server declarations:

client_max_body_size 1024M
client_max_body_buffer_size 128k

1 Comment

Add new comment