PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : آموزش نصب و کانفیگ php-fpm در دایرکت ادمین



Mohamad
02-23-2014, 09:16 AM
One requirement for this instruction to work is you need PHP 5.3. I have tried to patch PHP 5.2.17 according to PHP-FPM website but it didn't work. After tried to patch it so many times, I decided to upgrade to PHP 5.3.5 and it works correctly now.

Also, when compile PHP-FPM, you will get 2 PHP files. One is "php" which is for CLI mode and "php-fpm" which is PHP-FPM. "php-cgi" file won't be compiled until you removed "--enable-fpm" from configuration. That means... if you want to have the rest of Virtualhosts to run with mod_fcgid (php-cgi) with PHP 5.2, you can still do that. Just make sure to upgrade directly to PHP 5.3 and PHP-FPM at the same time. Always have "--enable-fpm" in configuration file for PHP to compile. That way, "php-cgi" will not compile in PHP version 5.3. So, all websites run with mod_fcgid that still use "php-cgi" file still run in PHP 5.2.
In case you need all of them to run in PHP 5.3. You need to compile PHP twice, one with "--enable-fpm" and one without it.
1. Enable PHP-FPM and compile PHP.
1.1 Copy "configure.php5" for custom compile



[*=left]mkdir -p /usr/local/directadmin/custombuild/custom/suphp
[*=left]cp /usr/local/directadmin/custombuild/configure/suphp/configure.php5 /usr/local/directadmin/custombuild/custom/suphp


1.2 Edit configure.php5


[*=left]nano -w /usr/local/directadmin/custombuild/custom/suphp/configure.php5


add "--enable-fpm" into the file. After edit, the "configure.php5" will look like below :


[*=left]#!/bin/sh
[*=left]"./configure" \
[*=left]"--prefix=/usr/local/php5" \
[*=left]"--enable-force-cgi-redirect" \
[*=left]"--enable-fastcgi" \
[*=left]"--with-config-file-path=/usr/local/etc/php5/cgi" \
[*=left]"--with-curl=/usr/local/lib" \
[*=left]"--with-gd" \
[*=left]"--with-gettext" \
[*=left]"--with-jpeg-dir=/usr/local/lib" \
[*=left]"--with-freetype-dir=/usr/local/lib" \
[*=left]"--with-kerberos" \
[*=left]"--with-mcrypt" \
[*=left]"--with-mhash" \
[*=left]"--with-mysql=/usr" \
[*=left]"--with-mysqli=/usr/bin/mysql_config" \
[*=left]"--with-pcre-regex=/usr/local" \
[*=left]"--with-pdo-mysql=/usr" \
[*=left]"--with-pear=/usr/local/lib/php" \
[*=left]"--with-png-dir=/usr/local/lib" \
[*=left]"--with-zlib" \
[*=left]"--with-zlib-dir=/usr/local/lib" \
[*=left]"--with-openssl" \
[*=left]"--with-iconv=/usr/local" \
[*=left]"--enable-bcmath" \
[*=left]"--enable-calendar" \
[*=left]"--enable-exif" \
[*=left]"--enable-ftp" \
[*=left]"--enable-gd-native-ttf" \
[*=left]"--enable-magic-quotes" \
[*=left]"--enable-soap" \
[*=left]"--enable-sockets" \
[*=left]"--enable-mbstring" \
[*=left]"--enable-zip" \
[*=left]"--enable-wddx" \
[*=left]"--enable-fpm"


1.3 Compile PHP


[*=left]cd /usr/local/directadmin/custombuild
[*=left]./build php n


Note : If you get error while compile, you may need to run " .build clean " and then try to compile again.
1.4 After compiled, you will see where PHP-FPM file located as below :


[*=left].....
[*=left]Make Complete
[*=left]Copying php.ini..
[*=left]/usr/local/etc/php5/cgi/php.ini already exists, skipping.
[*=left]Installing php...
[*=left]Installing PHP SAPI module: fpm
[*=left]Installing PHP CLI binary: /usr/local/php5/bin/
[*=left]Installing PHP CLI man page: /usr/local/php5/man/man1/
[*=left]Installing PHP FPM binary: /usr/local/php5/sbin/
[*=left]Installing PHP FPM config: /usr/local/php5/etc/
[*=left]Installing PHP FPM man page: /usr/local/php5/man/man8/
[*=left]Installing build environment: /usr/local/php5/lib/php/build/
[*=left]Installing header files: /usr/local/php5/include/php/
[*=left]Installing helper programs: /usr/local/php5/bin/
[*=left] program: phpize
[*=left] program: php-config
[*=left]Installing man pages: /usr/local/php5/man/man1/
[*=left] page: phpize.1
[*=left] page: php-config.1
[*=left]Installing PEAR environment: /usr/local/lib/php/
[*=left].....


2. Now, Create Init script file
2.1 Copy file from source


[*=left]cp /usr/local/directadmin/custombuild/php-5.3.5/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
[*=left]chmod 755 /etc/init.d/php-fpm


2.2 Edit php.fpm init script file as below:


[*=left]nano -w /etc/init.d/php-fpm


Edit php.fpm file FROM :


[*=left].....
[*=left]prefix=@prefix@
[*=left]exec_prefix=@exec_prefix@
[*=left]php_fpm_BIN=@sbindir@/php-fpm
[*=left]php_fpm_CONF=@sysconfdir@/php-fpm.conf
[*=left]php_fpm_PID=@localstatedir@/run/php-fpm.pid
[*=left]php_opts="--fpm-config $php_fpm_CONF"
[*=left].....


TO :


[*=left].....
[*=left]prefix=/usr/local/php5
[*=left]exec_prefix=${prefix}
[*=left]php_fpm_BIN=/usr/local/php5/sbin/php-fpm
[*=left]php_fpm_CONF=/usr/local/php5/etc/php-fpm.conf
[*=left]php_fpm_PID=/var/run/php-fpm.pid
[*=left]php_opts="--fpm-config $php_fpm_CONF"
[*=left].....


You may need to run command below to have PHP-FPM run automatically when start up (After reboot or turn on the machine) :


[*=left]/sbin/chkconfig php-fpm on


2.3 Edit PHP-FPM configuration file to match your need. My example below is just to make it work but you can adjust to whatever you like :


[*=left]nano -w /usr/local/php5/etc/php-fpm.conf


Below is my "php-fpm.conf" configuration :


[*=left][global]
[*=left]pid = /var/run/php-fpm.pid
[*=left]error_log = /var/log/php-fpm.log
[*=left][admin]
[*=left]listen = /fcgi/admin/public_html/admin.sock
[*=left]listen.owner = $pool
[*=left]listen.group = $pool
[*=left]listen.mode = 0666
[*=left]user = $pool
[*=left]group = $pool
[*=left]pm = dynamic
[*=left]pm.max_children = 50
[*=left]pm.start_servers = 3
[*=left]pm.min_spare_servers = 3
[*=left]pm.max_spare_servers = 10
[*=left]php_admin_value[open_basedir] = /home/$pool/:/tmp:/var/tmp:/var/www/html


Note 1 : $pool is variable which will replaced by the data from the bracket. Here, that is "admin".
Note 2 : php_admin_value[open_basedir] is not require but suggested. Also, without "/var/www/html", you won't be access your webmail or anything through domain name. However, you can still access webmail or anything through IP Address.
2.4 Try to start / stop / restart PHP-FPM



[*=left]service php-fpm start
[*=left]service php-fpm stop
[*=left]service php-fpm restart


Note :

1. To have PHP-FPM compiled and configured in this tutorial doesn't mean you already using it. It just means you already have PHP-FPM ready to use. You need to check my tutorial [HOW-TO] DirectAdmin - Run Apache with "mod_fcgid on PHP 5.2 / 5.3" and "mod_fastcgi + PHP-FPM on 5.3" on the same server that will be post soon.

Source :
- PHP: FastCGI Process Manager (FPM) - Manual (http://php.net/manual/en/install.fpm.php)
- The Life and Times of Michael Shadle » Cleanest configuration for the new PHP-FPM? (http://michaelshadle.com/2010/08/26/cleanest-configuration-for-the-new-php-fpm)
- Home - PHP-FPM (http://php-fpm.org)


Good luck :Şflower658Ş: