User Tools

Site Tools


xen

Table of Contents

Xen

xen-tools

Roles

In /etc/xen-tools/roles.d create a file called php5-fpm:

#!/bin/sh
#
#  Configure the new image to be a PHP5-FPM machine
#
prefix=$1


#
#  Source our common functions - this will let us install a Debian package.
#
if [ -e /usr/share/xen-tools/common.sh ]; then
    . /usr/share/xen-tools/common.sh
else
   echo "Unable to include /usr/share/xen-tools/common.sh - exiting!"
   exit
fi

#
#  Update APT lists.
#
chroot ${prefix} /usr/bin/apt-get update
chroot ${prefix} /usr/bin/apt-get -y upgrade

#
#  Install the packages
#
installDebianPackage ${prefix} libapparmor1
installDebianPackage ${prefix} libonig2
installDebianPackage ${prefix} libqdbm14
installDebianPackage ${prefix} php5-cli
installDebianPackage ${prefix} php5-common
installDebianPackage ${prefix} php5-fpm
installDebianPackage ${prefix} php5-json
installDebianPackage ${prefix} php5-readline
installDebianPackage ${prefix} screen

chroot ${prefix} /usr/sbin/update-rc.d php5-fpm enable

/bin/mkdir -p ${prefix}/etc/php5/fpm/pool.d

/bin/cat > ${prefix}/etc/php5/fpm/pool.d/lala.conf <<EOF
[lhh_sandbox]
prefix = /
user = www-data
group = www-data
listen = 10.18.16.63:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1,10.18.16.10,10.18.16.11,10.18.16.12,10.18.16.13
pm = dynamic
pm.max_children = 2000
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) /2
pm.start_servers = 250
pm.min_spare_servers = 250
pm.max_spare_servers = 500
;pm.process_idle_timeout = 10s;
pm.max_requests = 100000

pm.status_path = /adm_info/status.php
;ping.path = /ping

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.log.slow
request_slowlog_timeout = 20
;request_terminate_timeout = 5m
rlimit_files = 4096
;rlimit_core = 0
;chroot = \$prefix
chdir = /netmnt/www.lufthansaholidays.com/sandbox/current/web
catch_workers_output = yes
security.limit_extensions = .php .php5

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f binoli.de@my.domain.com
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/\$pool_php-fpm.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 4G

;php_admin_value[apc.ttl] = 10
;php_admin_value[apc.user_ttl] = 10

env[HOSTNAME] = \$HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /var/lib/php5/tmp
env[TMPDIR] = /var/lib/php5/tmp
env[TEMP] = /var/lib/php5/tmp
env[HOME] = /var/lib/php5
env[DOCUMENT_ROOT] = /netmnt/www.lufthansaholidays.com/sandbox/current/web'

EOF


Remember the Shebang line. Always use full paths to binaries. Keep an eye on escaping ''sh'' special characters.

==== Setting up a new VM ====

Open a GNU/screen session with 2 windows. Window 1:

<code>
# xen-create-image --hostname=fpm --dist=jessie --dir=/home/fgs --dhcp --noaccounts --noswap --size=10G --fs=ext4 --memory=1024M --password=h1ss1tAdm1n --vcpus=2 --role=php5-fpm

To follow the setup process, put this into window 2:

# tail -f /var/log/xen-tools/fpm.log
xen.txt · Last modified: 2015/05/07 09:55 by flo