php.yml 8.4 KB

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