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
- mkdir -p /usr/local/directadmin/custombuild/custom/suphp
- cp /usr/local/directadmin/custombuild/configure/suphp/configure.php5 /usr/local/directadmin/custombuild/custom/suphp
1.2 Edit configure.php5
- 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 :
- #!/bin/sh
- "./configure" \
- "--prefix=/usr/local/php5" \
- "--enable-force-cgi-redirect" \
- "--enable-fastcgi" \
- "--with-config-file-path=/usr/local/etc/php5/cgi" \
- "--with-curl=/usr/local/lib" \
- "--with-gd" \
- "--with-gettext" \
- "--with-jpeg-dir=/usr/local/lib" \
- "--with-freetype-dir=/usr/local/lib" \
- "--with-kerberos" \
- "--with-mcrypt" \
- "--with-mhash" \
- "--with-mysql=/usr" \
- "--with-mysqli=/usr/bin/mysql_config" \
- "--with-pcre-regex=/usr/local" \
- "--with-pdo-mysql=/usr" \
- "--with-pear=/usr/local/lib/php" \
- "--with-png-dir=/usr/local/lib" \
- "--with-zlib" \
- "--with-zlib-dir=/usr/local/lib" \
- "--with-openssl" \
- "--with-iconv=/usr/local" \
- "--enable-bcmath" \
- "--enable-calendar" \
- "--enable-exif" \
- "--enable-ftp" \
- "--enable-gd-native-ttf" \
- "--enable-magic-quotes" \
- "--enable-soap" \
- "--enable-sockets" \
- "--enable-mbstring" \
- "--enable-zip" \
- "--enable-wddx" \
- "--enable-fpm"
1.3 Compile PHP
- cd /usr/local/directadmin/custombuild
- ./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 :
- .....
- Make Complete
- Copying php.ini..
- /usr/local/etc/php5/cgi/php.ini already exists, skipping.
- Installing php...
- Installing PHP SAPI module: fpm
- Installing PHP CLI binary: /usr/local/php5/bin/
- Installing PHP CLI man page: /usr/local/php5/man/man1/
- Installing PHP FPM binary: /usr/local/php5/sbin/
- Installing PHP FPM config: /usr/local/php5/etc/
- Installing PHP FPM man page: /usr/local/php5/man/man8/
- Installing build environment: /usr/local/php5/lib/php/build/
- Installing header files: /usr/local/php5/include/php/
- Installing helper programs: /usr/local/php5/bin/
- program: phpize
- program: php-config
- Installing man pages: /usr/local/php5/man/man1/
- page: phpize.1
- page: php-config.1
- Installing PEAR environment: /usr/local/lib/php/
- .....
2. Now, Create Init script file
2.1 Copy file from source
- cp /usr/local/directadmin/custombuild/php-5.3.5/sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
- chmod 755 /etc/init.d/php-fpm
2.2 Edit php.fpm init script file as below:
- nano -w /etc/init.d/php-fpm
Edit php.fpm file FROM :
- .....
- prefix=@prefix@
- exec_prefix=@exec_prefix@
- php_fpm_BIN=@sbindir@/php-fpm
- php_fpm_CONF=@sysconfdir@/php-fpm.conf
- php_fpm_PID=@localstatedir@/run/php-fpm.pid
- php_opts="--fpm-config $php_fpm_CONF"
- .....
TO :
- .....
- prefix=/usr/local/php5
- exec_prefix=${prefix}
- php_fpm_BIN=/usr/local/php5/sbin/php-fpm
- php_fpm_CONF=/usr/local/php5/etc/php-fpm.conf
- php_fpm_PID=/var/run/php-fpm.pid
- php_opts="--fpm-config $php_fpm_CONF"
- .....
You may need to run command below to have PHP-FPM run automatically when start up (After reboot or turn on the machine) :
- /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 :
- nano -w /usr/local/php5/etc/php-fpm.conf
Below is my "php-fpm.conf" configuration :
- [global]
- pid = /var/run/php-fpm.pid
- error_log = /var/log/php-fpm.log
- [admin]
- listen = /fcgi/admin/public_html/admin.sock
- listen.owner = $pool
- listen.group = $pool
- listen.mode = 0666
- user = $pool
- group = $pool
- pm = dynamic
- pm.max_children = 50
- pm.start_servers = 3
- pm.min_spare_servers = 3
- pm.max_spare_servers = 10
- 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
- service php-fpm start
- service php-fpm stop
- 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 :
- http://php.net/manual/en/install.fpm.php
- http://michaelshadle.com/2010/08/26/cleanest-configuration-for-the-new-php-fpm
- http://php-fpm.org
آموزش نصب و کانفیگ مجازی ساز kvm
آموزش نصب VNC در Centos
آشنایی با 5 پلاگین کاربردی Nginx در وردپرس
آموزش نصب و فعالسازی SSL در سرورهای Cpanel
آموزش دانلود یک پوشه از یک سرور Remote
آموزش افزایش و بالا بردن امنیت WHMCS
آموزش ساخت صفحات اضافی در WHMCS
آشنایی با 15 دستور کاربردی در آنتی شل maldet
آموزش نصب و کانفیگ ftp سرور در CentOS 7
آموزش نصب phpmyadmin در nginx
آموزش نصب کلود لینوکس CloudLinux
آموزش تغییر IP و Hostname در Centos
آموزش شناسایی و حذف CryptoPHP PHP malware
آموزش افزایش امنیت سایت های جوملا Joomla
آموزش نصب Virtualizor روی centos 6.5
آشنایی با انواع Raid در سرور
آموزش نصب و کانفیگ php-fpm در دایرکت ادمین directadmin
آموزش نصب Spamassassin در دایرکت ادمین
آموزش خاموش کردن brute force notification
آموزش تنظیم mysql remote در دایرکت ادمین
سرویس کانفیگ ویژه امنیتی سرور
دستورالعمل جديد فعاليت سايت هاي چت روم
درباره پی سی سرور
تعطیلی 4 روزه بخش پشتیبانی
فروش ویژه سرورهای مجازی قدرتمند مختص چت روم های پربازدید
فروش ویژه سرور مجازی VPS بصورت مدیریت شده
خدمات مانیتورینگ و نگهداری و رفع اشکال سرور
کانفیگ سرورهای دایرکت ادمین
کانفیگ سرورهای سی پنل
اطلاعیه مهم: مدیران سایت های چت روم بخوانند
سیستم مدیریت محتوای سایت های عکس
راه اندازی سامانه پشتیبانی آنلاین پی سی سرور
سوء استفاده افراد کالاه بردار سود جو از نام پی سی پارسی
شروع بکار مجدد بخش پشتیبانی
تعطیلی 1 هفته ای بخش پشتیبانی بدلیل تغییر مکان شرکت
سیستم مدیریت محتوای سایت های تفریحی
سوء استفاده گروه سود جو "TopazVPS" گول نخورید
قوانین سرویس دهی پی سی سرور
طراحی چت روم
حفره امنیتی خطرناک در wordpress