Note this is more of a document blog than a question. Its intended to be as basis of the configuration required to enable php-fpm to speed up php code processing.
Note: This post is only about looking into options to speed up the fog web-gui front end and will have NO IMPACT on FOG imaging. I have another thread on what is required to make FOG Imaging faster.
For this post I’m focusing on Centos 7, but I suspect the configuration will be similar for Debian variants.
By default the fog installer installs php-fpm, but the fog installer doesn’t activate apache to use it. The follow steps are what I did to enable php-fpm to see if it would speed up the FOG web-gui. This speed up is not so much for interacting with the web-gui, but for the backend fog client that will check into the web master server every XX minutes to look for new tasks. If you have 1000 computers checking in every 5 minutes (fog default) then you will have (if averaged out) every second you will have 1.3 check ins. But we know that this check in time will be randomized where you might have 20 check ins within one second and nothing for 3 seconds then a flood again for the next.
- Edit the mpm configuration file to tell the apache mpm module to use events and not pre-fork
vi /etc/httpd/conf.modules.d/00-mpm.conf
- Comment out
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
- Uncomment
LoadModule mpm_event_module modules/mod_mpm_event.so
- Save and exit from 00-mpm.conf
- Change to the apache configuration directory
/etc/httpd/conf.d
- Copy the standard php.conf file to create a new php-fpm.conf file
cp /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php-fpm.conf
- Rename the original php.conf file so that apache won’t see it during startup
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disabled
- Edit the copied php-fpm.conf file
vi /etc/httpd/conf.d/php-fpm.conf
- Comment out the following line
#SetHandler application/x-httpd-php
- Insert the following line just below the commented out line
SetHandler "proxy:fcgi://127.0.0.1:9000"
- Save and exit the php-fpm.conf file
- Change to the php-fpm directory
cd /etc/php-fpm.d
- Remove the default www.conf in the php-fpm.d directory (this file is created by the fog installer and not used in this setup)
rm /etc/php-fpm.d/www.conf
- Create a new file called fog.conf
vi /etc/php-fpm.d/fog.conf
- Paste in the following
[fog]
user = apache
group = apache
listen = 127.0.0.1:9000
;listen.owner = apache
;listen.group = apache
;listen.mode = 0660
;listen.acl_users = apache
;listen.acl_groups =
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
;pm.process_idle_timeout = 10s;
pm.max_requests = 500
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
access.log = /var/log/php-fpm/$pool.access.log
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
slowlog = /var/log/php-fpm/$pool-slow.log
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/fog-error.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 128M
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
; we will use these settings when memcache (d) is configured.
;php_value[session.save_handler] = memcached
;php_value[session.save_path] = "127.0.0.1:11211"
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
- Save and exit fog.conf
- Create a php information page in the web root
vi /var/www/html/info.php
- Paste in the following
<html>
<body>
<?php
phpinfo();
?>
</body>
</html>
- Save and exit info.php page.
- Change the owner of that page to apache
chown apache:apache /var/www/html/info.php
- From a web browser call the info page with http://<fog_server_ip>/info.php. The page should look similar to below
<insert_info_page_image> - Now lets restart both apache and php-fpm
systemctl restart php-fpm
systemctl restart httpd
- Give it a few seconds for both services to initialize.
- Now call the same info.php page. The page should look similar to below. NOTE: that the Server API variable is now ‘FPM/FastCGI’
<insert_info_page_image> - Now access the FOG management page console
- Access a few of the managment pages, you will note that after a few page clicks the pages will respond faster to your page selections.
- To confirm that php-fpm is working you can inspect the logs files being created in /var/log/php-fpm directory. The php errors will now be listed there instead of the default apache error log (because php-fpm is now handling the php code).
- You may remove the info.php page in the apache root directory. Its no longer needed.
- Done (for now, I’m currently looking into the memcache option. But more on that later).
With these updates we have now handed off php code execution to a dedicated php engine and we are no longer relying on apache to execute both web pages management and php code execution. Will this help the sites that have hundreds of clients? I hope so.
Next steps installing memcache