php.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. - name: 'Install common PHP dependencies (Debian <= 8)'
  2. apt:
  3. pkg: '{{ item }}'
  4. state: 'installed'
  5. with_items:
  6. - 'php5-cli'
  7. - 'php5-curl'
  8. - 'php5-gd'
  9. - 'php5-intl'
  10. - 'php5-mcrypt'
  11. - 'php-mime-type'
  12. - 'php5-pgsql'
  13. - 'php5-sqlite'
  14. when: with_php and ansible_lsb.major_release|int <= 8
  15. - name: 'Install common PHP dependencies (Debian >= 9)'
  16. apt:
  17. pkg: '{{ item }}'
  18. state: 'installed'
  19. with_items:
  20. - 'php{{ php_version }}-cli'
  21. - 'php{{ php_version }}-curl'
  22. - 'php{{ php_version }}-gd'
  23. - 'php{{ php_version }}-intl'
  24. - 'php{{ php_version }}-mcrypt'
  25. - 'php{{ php_version }}-mysql'
  26. - 'php{{ php_version }}-pgsql'
  27. - 'php{{ php_version }}-sqlite3'
  28. - 'php-mime-type'
  29. when: with_php and ansible_lsb.major_release|int >= 9
  30. - name: 'Create PHP log directory'
  31. file:
  32. path: '/var/log/php'
  33. state: directory
  34. owner: 'root'
  35. group: 'root'
  36. mode: 0755
  37. when: with_fpm
  38. - name: 'Install PHP configuration for syslog'
  39. template:
  40. src: '{{ item.src }}'
  41. dest: '{{ item.dest }}'
  42. owner: 'root'
  43. group: 'root'
  44. mode: 0644
  45. with_items:
  46. - { src: 'rsyslog/php-errors.conf.j2', dest: '/etc/rsyslog.d/php-errors.conf' }
  47. - { src: 'logrotate/php-errors.j2', dest: '/etc/logrotate.d/php-errors' }
  48. notify:
  49. - 'Reload rsyslog for php'
  50. when: with_fpm
  51. - name: 'Install local PHP configuration overrides for php5-cli (Debian 8)'
  52. template:
  53. src: 'php/php-config-cli.ini.j2'
  54. dest: '/etc/php5/cli/conf.d/99-local-config.ini'
  55. owner: 'root'
  56. group: 'root'
  57. mode: 0644
  58. when: with_php and ansible_lsb.major_release|int == 8
  59. - name: 'Install local PHP configuration overrides for php{{ php_version }}-cli (Debian >= 9)'
  60. template:
  61. src: 'php/php-config-cli.ini.j2'
  62. dest: '/etc/php/{{php_version }}/cli/conf.d/99-local-config.ini'
  63. owner: 'root'
  64. group: 'root'
  65. mode: 0644
  66. when: with_php and ansible_lsb.major_release|int >= 9
  67. - name: 'Install Apache2 module for php5'
  68. apt:
  69. pkg: 'libapache2-mod-php5'
  70. state: 'installed'
  71. when: with_modphp5
  72. - name: 'Install Apache2 module for php{{ php_version }}'
  73. apt:
  74. pkg: 'libapache2-mod-php{{php_version}}'
  75. state: 'installed'
  76. when: with_modphp
  77. - name: 'Install local PHP configuration (Debian < 8)'
  78. template:
  79. src: 'php/php-config-web.ini.j2'
  80. dest: '/etc/php5/conf.d/99-local-config.ini'
  81. owner: 'root'
  82. group: 'root'
  83. mode: 0644
  84. when: with_modphp5 and ansible_lsb.major_release|int < 8
  85. - name: 'Install local PHP configuration for Apache 2 (Debian 8)'
  86. template:
  87. src: 'php/php-config-web.ini.j2'
  88. dest: '/etc/php5/apache2/conf.d/99-local-config.ini'
  89. owner: 'root'
  90. group: 'root'
  91. mode: 0644
  92. when: with_modphp5 and ansible_lsb.major_release|int == 8
  93. - name: 'Install local PHP configuration for Apache 2 (Debian >= 9)'
  94. template:
  95. src: 'php/php-config-web.ini.j2'
  96. dest: '/etc/php/{{ php_version }}/apache2/conf.d/99-local-config.ini'
  97. owner: 'root'
  98. group: 'root'
  99. mode: 0644
  100. when: with_modphp5 and ansible_lsb.major_release|int >= 9
  101. - name: 'Create system checks directory /etc/phpsyscheck'
  102. file:
  103. path: '/etc/phpsyscheck'
  104. state: 'directory'
  105. owner: 'root'
  106. group: 'root'
  107. mode: 0755
  108. - name: 'Install phpinfo system check'
  109. template:
  110. src: 'php/phpinfo.php'
  111. dest: '/etc/phpsyscheck/index.php'
  112. owner: 'root'
  113. group: 'root'
  114. mode: 0644
  115. - name: 'Install PHP APC extension (Debian <= 8)'
  116. apt:
  117. pkg: 'php-apc'
  118. state: 'installed'
  119. when: with_php_apc and ansible_lsb.major_release|int <= 8
  120. - name: 'Install PHP APC extension (Debian >= 9)'
  121. apt:
  122. pkg: 'php-apcu'
  123. state: 'installed'
  124. when: with_php_apc and ansible_lsb.major_release|int >= 9
  125. - name: 'Install php-apc system check'
  126. template:
  127. src: 'php/apc.php'
  128. dest: '/etc/phpsyscheck/apc.php'
  129. owner: 'root'
  130. group: 'root'
  131. mode: 0644
  132. when: with_php_apc
  133. - name: 'Install MySQL extension for PHP - native driver (Debian 8)'
  134. apt:
  135. pkg: 'php5-mysqlnd'
  136. state: 'installed'
  137. when: not with_php_mysql_legacy and ansible_lsb.major_release|int == 8
  138. - name: 'Install MySQL extension for PHP (old driver)'
  139. apt:
  140. pkg: 'php5-mysql'
  141. state: 'installed'
  142. when: with_php_mysql_legacy
  143. - name: 'Install PHPMyAdmin'
  144. apt:
  145. pkg: 'phpmyadmin'
  146. state: 'installed'
  147. when: with_phpmyadmin
  148. - name: 'Install PHPPgAdmin'
  149. apt:
  150. pkg: 'phppgadmin'
  151. state: 'installed'
  152. when: with_phppgadmin
  153. - name: 'Install FPM for PHP 5 (Debian <= 8)'
  154. apt:
  155. pkg: 'php5-fpm'
  156. state: 'installed'
  157. when: with_fpm and ansible_lsb.major_release|int < 8
  158. - name: 'Install FPM for PHP {{ php_version }} (Debian >= 9)'
  159. apt:
  160. pkg: 'php{{ php_version }}-fpm'
  161. state: 'installed'
  162. when: with_fpm and ansible_lsb.major_release|int >= 9
  163. - name: 'Configure FPM for PHP 5 (Debian <= 8)'
  164. lineinfile:
  165. dest: '/etc/php5/fpm/php-fpm.conf'
  166. regexp: '^{{item.key}}\s*=.*$'
  167. line: '{{item.key}} = {{item.value}}'
  168. insertafter: '^;{{item.key}}'
  169. with_items:
  170. - { key: 'error_log', value: 'syslog' }
  171. - { key: 'log_level', value: 'warning' }
  172. - { key: 'emergency_restart_threshold', value: '100' }
  173. - { key: 'emergency_restart_interval', value: '5s' }
  174. - { key: 'rlimit_files', value: '262144' }
  175. - { key: 'events.mechanism', value: 'epoll' }
  176. - { key: 'include', value: '/etc/php5/fpm/pool.d/local-pool.cnf' }
  177. when: with_fpm and ansible_lsb.major_release|int < 8
  178. - name: 'Configure FPM for PHP {{ php_version }} (Debian >= 9)'
  179. lineinfile:
  180. dest: '/etc/php/{{ php_version }}/fpm/php-fpm.conf'
  181. regexp: '^{{item.key}}\s*=.*$'
  182. line: '{{item.key}} = {{item.value}}'
  183. insertafter: '^;{{item.key}}'
  184. with_items:
  185. - { key: 'error_log', value: 'syslog' }
  186. - { key: 'log_level', value: 'warning' }
  187. - { key: 'emergency_restart_threshold', value: '100' }
  188. - { key: 'emergency_restart_interval', value: '5s' }
  189. - { key: 'rlimit_files', value: '262144' }
  190. - { key: 'events.mechanism', value: 'epoll' }
  191. - { key: 'include', value: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf' }
  192. when: with_fpm and ansible_lsb.major_release|int < 8
  193. - name: 'Install FPM pools configuration for PHP 5 (Debian <= 8)'
  194. template:
  195. src: 'fpm/php5-fpm-pools.conf.j2'
  196. dest: '/etc/php5/fpm/pool.d/local-pool.cnf'
  197. owner: 'root'
  198. group: 'root'
  199. mode: 0644
  200. notify:
  201. - 'Reload FPM for PHP 5'
  202. when: with_fpm and ansible_lsb.major_release|int <= 8
  203. - name: 'Install FPM pools configuration for PHP {{ php_version }} (Debian > 9)'
  204. template:
  205. src: 'fpm/php-fpm-pools.conf.j2'
  206. dest: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf'
  207. owner: 'root'
  208. group: 'root'
  209. mode: 0644
  210. notify:
  211. - 'Reload FPM for PHP'
  212. when: with_fpm and ansible_lsb.major_release|int >= 9
  213. - name: 'Install local PHP configuration overrides for php5-fpm (Debian 8)'
  214. template:
  215. src: 'php/php-config-web.ini.j2'
  216. dest: '/etc/php5/fpm/conf.d/99-local-config.ini'
  217. owner: 'root'
  218. group: 'root'
  219. mode: 0644
  220. when: with_fpm and ansible_lsb.major_release|int == 8
  221. - name: 'Install local PHP configuration overrides for php{{ php_version }}-fpm (Debian >= 9)'
  222. template:
  223. src: 'php/php-config-web.ini.j2'
  224. dest: '/etc/php/{{ php_version }}/fpm/conf.d/99-local-config.ini'
  225. owner: 'root'
  226. group: 'root'
  227. mode: 0644
  228. when: with_fpm and ansible_lsb.major_release|int >= 9
  229. - name: 'Install Nginx config files for PHP FPM (fpm servers pool)'
  230. template:
  231. src: 'fpm/nginx/fpm-pool.conf.j2'
  232. dest: '/etc/nginx/conf.d/fpm-pool.conf'
  233. owner: 'root'
  234. group: 'root'
  235. mode: 0644
  236. notify:
  237. - 'Reload nginx'
  238. when: with_fpm and with_nginx
  239. - name: 'Install Nginx config files for PHP FPM (fpm fastcgi config)'
  240. template:
  241. src: 'fpm/nginx/fastcgi_pass_fpm.j2'
  242. dest: '/etc/nginx/fastcgi_pass_fpm'
  243. owner: 'root'
  244. group: 'root'
  245. mode: 0644
  246. notify:
  247. - 'Reload nginx'
  248. when: with_fpm and with_nginx
  249. - name: 'Ensure FPM for PHP 5 is running (Debian <= 8)'
  250. service:
  251. name: 'php5-fpm'
  252. state: 'started'
  253. when: with_fpm and ansible_lsb.major_release|int <= 8
  254. - name: 'Ensure FPM for PHP {{ php_version }} is running (Debian >= 9)'
  255. service:
  256. name: 'php{{ php_version }}-fpm'
  257. state: 'started'
  258. when: with_fpm and ansible_lsb.major_release|int >= 9
  259. # vim: ft=ansible