When configuration php-fpm you are able to configure it using ports or sockets.
The best thing to do is configure with socks as this avoids the networking stack associated with ports.
This means that php-fpm will be using files (sockets) to run which could be considered slower because of potential slow HDDs however the files are mostly stored in RAM so it makes accessing them significantly quicker.
CentOS 6 uses FHS 2.3, this means that it uses /dev/shm for accessing RAM
Sockets | fastcgi_pass unix:/dev/shm/php-fpm-example.com.sock |
---|---|
Ports | fastcgi_pass 127.0.0.1:9000; |
You can see from the output below the tmpfs (temporary file system) is mounted to /dev/shm:
# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 1.8T 194G 1.6T 12% / tmpfs 1.9G 4.0K 1.9G 1% /dev/shm /dev/sda1 190M 88M 93M 49% /boot
To specify different server pools for each website you can create a website pool in the /etc/php-fpm.d/ directory.
E.g /etc/php-fpm.d/lukeslinux.co.uk
You would then want something similar to the following:
[lukeslinux.co.uk] listen = /dev/shm/php-fpm-lukeslinux.co.uk.sock listen.allowed_clients = 127.0.0.1 user = nginx group = nginx pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 slowlog = /var/log/php-fpm/lukeslinux.co.uk-slow.log php_admin_value[error_log] = /var/log/php-fpm/lukeslinux.co.uk-error.log php_admin_flag[log_errors] = on php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session
If you are looking to view the processes, you will need to use different commands depending on how its been configured:
Config | Command | |
---|---|---|
socket | netstat -plnx | grep 'php-fpm' |
port | netstat -plnt | grep 'php-fpm |
Example output of netstat -plnx:
unix 2 [ ACC ] STREAM LISTENING 146689 21372/php-fpm: mast /dev/shm/php-fpm-lukeslinux.co.uk.sock
Make sure that php-fpm hasnt hit max processes;
grep "pm.max_spare_servers" /etc/php-fpm.d/www.conf
ps -eo cmd,pid,pcpu --sort:-pcpu | grep -v grep | grep -c php-fpm