php.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. - name: Install common PHP dependencies
  2. apt: pkg={{ item }} state=installed
  3. with_items:
  4. - php5-cli
  5. - php5-curl
  6. - php5-gd
  7. - php5-intl
  8. - php5-mcrypt
  9. - php-mime-type
  10. - php5-pgsql
  11. - php5-sqlite
  12. - name: Create PHP log directory
  13. file: path=/var/log/php state=directory owner=root group=root mode=0755
  14. when: with_fpm
  15. - name: Install PHP configuration for syslog
  16. template: src={{ item.src }} dest={{ item.dest }} owner=root group=root mode=0644
  17. with_items:
  18. - { src: 'rsyslog/php-errors.conf.j2', dest: '/etc/rsyslog.d/php-errors.conf' }
  19. - { src: 'logrotate/php-errors.j2', dest: '/etc/logrotate.d/php-errors' }
  20. notify:
  21. - Reload rsyslog for php
  22. when: with_fpm
  23. - name: Install local PHP configuration overrides for php5-cli (Debian >= 8)
  24. template: src=php/php-config-cli.ini.j2 dest=/etc/php5/cli/conf.d/99-local-config.ini owner=root group=root mode=0644
  25. when: with_php and ansible_lsb.major_release|int >= 8
  26. - name: Install mod_php5 packages for apache2
  27. apt: pkg=libapache2-mod-php5 state=installed
  28. when: with_modphp5
  29. - name: Install local PHP configuration (Debian < 8)
  30. template: src=php/php-config-web.ini.j2 dest=/etc/php5/conf.d/99-local-config.ini owner=root group=root mode=0644
  31. when: with_modphp5 and ansible_lsb.major_release|int < 8
  32. - name: Install local PHP apache2 configuration (Debian >= 8)
  33. template: src=php/php-config-web.ini.j2 dest=/etc/php5/apache2/conf.d/99-local-config.ini owner=root group=root mode=0644
  34. when: with_modphp5 and ansible_lsb.major_release|int >= 8
  35. - name: Create system checks directory /etc/php5/syscheck.d
  36. file: path=/etc/php5/syscheck.d owner=root group=root mode=0755 state=directory
  37. - name: 'Create system checks directory /etc/phpsyscheck'
  38. file:
  39. path: '/etc/phpsyscheck'
  40. state: 'directory'
  41. owner: 'root'
  42. group: 'root'
  43. mode: 0755
  44. - name: 'Install phpinfo system check'
  45. template:
  46. src: 'php/phpinfo.php'
  47. dest: '/etc/phpsyscheck/index.php'
  48. owner: 'root'
  49. group: 'root'
  50. mode: 0644
  51. - name: 'Install PHP APC extension (Debian <= 8)'
  52. apt:
  53. pkg: 'php-apc'
  54. state: 'installed'
  55. when: with_php_apc and ansible_lsb.major_release|int <= 8
  56. - name: Install php-apc system check
  57. template: src=php/apc.php dest=/etc/php5/syscheck.d/apc.php owner=root group=root mode=0644
  58. when: with_php_apc
  59. - name: Install MySQL extension for PHP (native driver)
  60. apt: pkg=php5-mysqlnd state=installed
  61. when: not with_php_mysql_legacy
  62. - name: Install MySQL extension for PHP (old driver)
  63. apt: pkg=php5-mysql state=installed
  64. when: with_php_mysql_legacy
  65. - name: Install PHPMyAdmin
  66. apt: pkg=phpmyadmin state=installed
  67. when: with_phpmyadmin
  68. - name: Install PHPPgAdmin
  69. apt: pkg=phppgadmin state=installed
  70. when: with_phppgadmin
  71. - name: Install php5-fpm package
  72. apt: pkg=php5-fpm state=installed
  73. when: with_fpm
  74. - name: Install php5-fpm init script config file
  75. template: src=fpm/default.j2 dest=/etc/default/php5-fpm owner=root group=root mode=0644
  76. notify:
  77. - Restart php5-fpm
  78. when: with_fpm
  79. - name: Configure php5-fpm
  80. lineinfile: dest=/etc/php5/fpm/php-fpm.conf regexp="^{{item.key}}\s*=.*$" line="{{item.key}} = {{item.value}}" insertafter="^;{{item.key}}"
  81. with_items:
  82. - { key: 'error_log', value: 'syslog' }
  83. - { key: 'log_level', value: 'warning' }
  84. - { key: 'emergency_restart_threshold', value: '100' }
  85. - { key: 'emergency_restart_interval', value: '5s' }
  86. - { key: 'rlimit_files', value: '262144' }
  87. - { key: 'events.mechanism', value: 'epoll' }
  88. - { key: 'include', value: '/etc/php5/fpm/pool.d/local-pool.cnf' }
  89. when: with_fpm
  90. - name: Install php5-fpm pools configuration file
  91. template: src=fpm/php-fpm-pools.conf.j2 dest=/etc/php5/fpm/pool.d/local-pool.cnf owner=root group=root mode=0644
  92. notify:
  93. - Restart php5-fpm
  94. when: with_fpm
  95. - name: Install local PHP configuration overrides for php5-fpm (Debian >= 8)
  96. template: src=php/php-config-web.ini.j2 dest=/etc/php5/fpm/conf.d/99-local-config.ini owner=root group=root mode=0644
  97. when: with_fpm and ansible_lsb.major_release|int >= 8
  98. - name: Install nginx config files for php5-fpm (fpm servers pool)
  99. template: src=fpm/nginx/fpm-pool.conf.j2 dest=/etc/nginx/conf.d/fpm-pool.conf owner=root group=root mode=0644
  100. notify:
  101. - Reload nginx
  102. when: with_fpm and with_nginx
  103. - name: Install nginx config files for php5-fpm (fpm fastcgi config)
  104. template: src=fpm/nginx/fastcgi_pass_fpm.j2 dest=/etc/nginx/fastcgi_pass_fpm owner=root group=root mode=0644
  105. notify:
  106. - Reload nginx
  107. when: with_fpm and with_nginx
  108. - name: Ensure php5-fpm is running
  109. service: name=php5-fpm state=started
  110. when: with_fpm