php.yml 8.3 KB

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