php.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. - name: 'Install common PHP dependencies (Debian <= 8)'
  2. apt:
  3. pkg:
  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. state: 'present'
  13. when: with_php|bool and ansible_lsb.major_release|int <= 8
  14. tags:
  15. - 'web'
  16. - 'php'
  17. - name: 'Install common PHP dependencies (Debian >= 9, PHP version {{ php_version }})'
  18. apt:
  19. pkg:
  20. - 'php{{ php_version }}-cli'
  21. - 'php{{ php_version }}-curl'
  22. - 'php{{ php_version }}-gd'
  23. - 'php{{ php_version }}-intl'
  24. - 'php{{ php_version }}-mysql'
  25. - 'php{{ php_version }}-pgsql'
  26. - 'php{{ php_version }}-sqlite3'
  27. - 'php{{ php_version }}-zip'
  28. state: 'present'
  29. when: with_php|bool and ansible_lsb.major_release|int >= 9
  30. tags:
  31. - 'web'
  32. - 'php'
  33. - name: 'Install common PHP dependencies (Debian >= 9, PHP < 7.2, PHP version {{ php_version }})'
  34. apt:
  35. pkg:
  36. - 'php{{ php_version }}-mcrypt'
  37. state: 'present'
  38. when: with_php|bool and ansible_lsb.major_release|int >= 9 and php_version|float < 7.2
  39. tags:
  40. - 'web'
  41. - 'php'
  42. - name: 'Create PHP log directory'
  43. file:
  44. path: '/var/log/php'
  45. state: directory
  46. owner: 'root'
  47. group: 'root'
  48. mode: '0755'
  49. when: with_php|bool
  50. tags:
  51. - 'web'
  52. - 'php'
  53. - name: 'Install PHP configuration for syslog'
  54. template:
  55. src: '{{ item.src }}'
  56. dest: '{{ item.dest }}'
  57. owner: 'root'
  58. group: 'root'
  59. mode: '0644'
  60. with_items:
  61. - { src: 'rsyslog/php-errors.conf.j2', dest: '/etc/rsyslog.d/php-errors.conf' }
  62. - { src: 'logrotate/php-errors.j2', dest: '/etc/logrotate.d/php-errors' }
  63. notify:
  64. - 'Reload rsyslog for php'
  65. when: with_fpm|bool
  66. tags:
  67. - 'web'
  68. - 'php'
  69. - name: 'Install local PHP configuration overrides for php5-cli (Debian 8)'
  70. template:
  71. src: 'php/php-config-cli.ini.j2'
  72. dest: '/etc/php5/cli/conf.d/99-local-config.ini'
  73. owner: 'root'
  74. group: 'root'
  75. mode: '0644'
  76. when: with_php|bool and ansible_lsb.major_release|int == 8
  77. tags:
  78. - 'web'
  79. - 'php'
  80. - name: 'Install local PHP configuration overrides for php{{ php_version }}-cli (Debian >= 9)'
  81. template:
  82. src: 'php/php-config-cli.ini.j2'
  83. dest: '/etc/php/{{ php_version }}/cli/conf.d/99-local-config.ini'
  84. owner: 'root'
  85. group: 'root'
  86. mode: '0644'
  87. when: with_php|bool and ansible_lsb.major_release|int >= 9
  88. tags:
  89. - 'web'
  90. - 'php'
  91. - name: 'Install Apache2 module for php5'
  92. apt:
  93. pkg:
  94. - 'libapache2-mod-php5'
  95. state: 'present'
  96. notify:
  97. - 'Reload apache2'
  98. when: with_modphp5|bool
  99. tags:
  100. - 'web'
  101. - 'php'
  102. - name: 'Install Apache2 module for php{{ php_version }}'
  103. apt:
  104. pkg:
  105. - 'libapache2-mod-php{{ php_version }}'
  106. state: 'present'
  107. notify:
  108. - 'Reload apache2'
  109. when: with_modphp|bool
  110. tags:
  111. - 'web'
  112. - 'php'
  113. - name: 'Configure Apache2 modules for php-fpm{{ php_version }}'
  114. shell: a2dismod php{{ php_version }} mpm_prefork ; a2enmod mpm_event proxy_fcgi
  115. changed_when: False
  116. when: with_fpm|bool and with_apache2|bool
  117. notify:
  118. - 'Reload apache2'
  119. tags:
  120. - 'web'
  121. - 'php'
  122. - name: 'Configure Apache2 modules for modphp{{ php_version }}'
  123. shell: a2dismod mpm_event ; a2enmod mpm_prefork php{{ php_version }}
  124. changed_when: False
  125. when: with_modphp|bool
  126. notify:
  127. - 'Reload apache2'
  128. tags:
  129. - 'web'
  130. - 'php'
  131. - name: 'Install local PHP configuration (Debian < 8)'
  132. template:
  133. src: 'php/php-config-web.ini.j2'
  134. dest: '/etc/php5/conf.d/99-local-config.ini'
  135. owner: 'root'
  136. group: 'root'
  137. mode: '0644'
  138. notify:
  139. - 'Reload apache2'
  140. when: with_modphp5|bool and ansible_lsb.major_release|int < 8
  141. tags:
  142. - 'web'
  143. - 'php'
  144. - name: 'Install local PHP configuration for Apache 2 (Debian 8)'
  145. template:
  146. src: 'php/php-config-web.ini.j2'
  147. dest: '/etc/php5/apache2/conf.d/99-local-config.ini'
  148. owner: 'root'
  149. group: 'root'
  150. mode: '0644'
  151. notify:
  152. - 'Reload apache2'
  153. when: with_modphp5|bool and ansible_lsb.major_release|int == 8
  154. tags:
  155. - 'web'
  156. - 'php'
  157. - name: 'Install local PHP configuration for Apache 2 (Debian >= 9)'
  158. template:
  159. src: 'php/php-config-web.ini.j2'
  160. dest: '/etc/php/{{ php_version }}/apache2/conf.d/99-local-config.ini'
  161. owner: 'root'
  162. group: 'root'
  163. mode: '0644'
  164. notify:
  165. - 'Reload apache2'
  166. when: with_modphp|bool and ansible_lsb.major_release|int >= 9
  167. tags:
  168. - 'web'
  169. - 'php'
  170. - name: 'Create system checks directory /etc/phpsyscheck'
  171. file:
  172. path: '/etc/phpsyscheck'
  173. state: 'directory'
  174. owner: 'root'
  175. group: 'root'
  176. mode: '0755'
  177. when: with_phpsyscheck|bool
  178. tags:
  179. - 'web'
  180. - 'php'
  181. - name: 'Install phpinfo system check'
  182. template:
  183. src: 'php/phpinfo.php'
  184. dest: '/etc/phpsyscheck/index.php'
  185. owner: 'root'
  186. group: 'root'
  187. mode: '0644'
  188. when: with_phpsyscheck|bool
  189. tags:
  190. - 'web'
  191. - 'php'
  192. - name: 'Install PHP APC extension (Debian <= 8)'
  193. apt:
  194. pkg:
  195. - 'php-apc'
  196. state: 'present'
  197. when: with_php_apc|bool and ansible_lsb.major_release|int <= 8
  198. tags:
  199. - 'web'
  200. - 'php'
  201. - name: 'Install PHP APC extension (Debian >= 9)'
  202. apt:
  203. pkg:
  204. - 'php-apcu'
  205. state: 'present'
  206. when: with_php_apc|bool and ansible_lsb.major_release|int >= 9
  207. tags:
  208. - 'web'
  209. - 'php'
  210. - name: 'Install php-apc system check'
  211. template:
  212. src: 'php/apc.php'
  213. dest: '/etc/phpsyscheck/apc.php'
  214. owner: 'root'
  215. group: 'root'
  216. mode: '0644'
  217. when: with_phpsyscheck|bool and with_php_apc|bool
  218. tags:
  219. - 'web'
  220. - 'php'
  221. - name: 'Install MySQL extension for PHP - native driver (Debian 8)'
  222. apt:
  223. pkg:
  224. - 'php5-mysqlnd'
  225. state: 'present'
  226. when: not with_php_mysql_legacy|bool and ansible_lsb.major_release|int == 8
  227. tags:
  228. - 'web'
  229. - 'php'
  230. - name: 'Install MySQL extension for PHP (old driver)'
  231. apt:
  232. pkg: 'php5-mysql'
  233. state: 'present'
  234. when: with_php_mysql_legacy|bool
  235. tags:
  236. - 'web'
  237. - 'php'
  238. - name: 'Install PHPMyAdmin'
  239. apt:
  240. pkg:
  241. - 'phpmyadmin'
  242. state: 'present'
  243. when: with_phpmyadmin|bool
  244. tags:
  245. - 'web'
  246. - 'php'
  247. - name: 'Install PHPPgAdmin'
  248. apt:
  249. pkg:
  250. - 'phppgadmin'
  251. state: 'present'
  252. when: with_phppgadmin|bool
  253. tags:
  254. - 'web'
  255. - 'php'
  256. - name: 'Install FPM for PHP 5 (Debian <= 8)'
  257. apt:
  258. pkg:
  259. - 'php5-fpm'
  260. state: 'present'
  261. when: with_fpm|bool and ansible_lsb.major_release|int <= 8
  262. tags:
  263. - 'web'
  264. - 'php'
  265. - name: 'Install FPM for PHP {{ php_version }} (Debian >= 9)'
  266. apt:
  267. pkg:
  268. - 'php{{ php_version }}-fpm'
  269. state: 'present'
  270. when: with_fpm|bool and ansible_lsb.major_release|int >= 9
  271. tags:
  272. - 'web'
  273. - 'php'
  274. - name: 'Configure FPM for PHP 5 (Debian <= 8)'
  275. lineinfile:
  276. dest: '/etc/php5/fpm/php-fpm.conf'
  277. regexp: '^{{ item.key }}\s*=.*$'
  278. line: '{{ item.key }} = {{ item.value }}'
  279. insertafter: '^;{{ item.key }}'
  280. with_items:
  281. - { key: 'error_log', value: 'syslog' }
  282. - { key: 'log_level', value: 'warning' }
  283. - { key: 'emergency_restart_threshold', value: '100' }
  284. - { key: 'emergency_restart_interval', value: '5s' }
  285. - { key: 'rlimit_files', value: '262144' }
  286. - { key: 'events.mechanism', value: 'epoll' }
  287. - { key: 'include', value: '/etc/php5/fpm/pool.d/local-pool.cnf' }
  288. notify:
  289. - 'Reload FPM for PHP 5'
  290. when: with_fpm|bool and ansible_lsb.major_release|int <= 8
  291. tags:
  292. - 'web'
  293. - 'php'
  294. - name: 'Configure FPM for PHP {{ php_version }} (Debian >= 9)'
  295. lineinfile:
  296. dest: '/etc/php/{{ php_version }}/fpm/php-fpm.conf'
  297. regexp: '^{{ item.key }}\s*=.*$'
  298. line: '{{ item.key }} = {{ item.value }}'
  299. insertafter: '^;{{ item.key }}'
  300. with_items:
  301. - { key: 'error_log', value: 'syslog' }
  302. - { key: 'log_level', value: 'warning' }
  303. - { key: 'emergency_restart_threshold', value: '100' }
  304. - { key: 'emergency_restart_interval', value: '5s' }
  305. - { key: 'rlimit_files', value: '262144' }
  306. - { key: 'events.mechanism', value: 'epoll' }
  307. - { key: 'include', value: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf' }
  308. notify:
  309. - 'Reload FPM for PHP'
  310. when: with_fpm|bool and ansible_lsb.major_release|int >= 9
  311. tags:
  312. - 'web'
  313. - 'php'
  314. - name: 'Install FPM pools configuration for PHP 5 (Debian <= 8)'
  315. template:
  316. src: 'fpm/php5-fpm-pools.conf.j2'
  317. dest: '/etc/php5/fpm/pool.d/local-pool.cnf'
  318. owner: 'root'
  319. group: 'root'
  320. mode: '0644'
  321. notify:
  322. - 'Reload FPM for PHP 5'
  323. when: with_fpm|bool and ansible_lsb.major_release|int <= 8
  324. tags:
  325. - 'web'
  326. - 'php'
  327. - name: 'Install FPM pools configuration for PHP {{ php_version }} (Debian > 9)'
  328. template:
  329. src: 'fpm/php-fpm-pools.conf.j2'
  330. dest: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf'
  331. owner: 'root'
  332. group: 'root'
  333. mode: '0644'
  334. notify:
  335. - 'Reload FPM for PHP'
  336. when: with_fpm|bool and ansible_lsb.major_release|int >= 9
  337. tags:
  338. - 'web'
  339. - 'php'
  340. - name: 'Install local PHP configuration overrides for php5-fpm (Debian 8)'
  341. template:
  342. src: 'php/php-config-web.ini.j2'
  343. dest: '/etc/php5/fpm/conf.d/99-local-config.ini'
  344. owner: 'root'
  345. group: 'root'
  346. mode: '0644'
  347. when: with_fpm|bool and ansible_lsb.major_release|int == 8
  348. tags:
  349. - 'web'
  350. - 'php'
  351. - name: 'Install local PHP configuration overrides for php{{ php_version }}-fpm (Debian >= 9)'
  352. template:
  353. src: 'php/php-config-web.ini.j2'
  354. dest: '/etc/php/{{ php_version }}/fpm/conf.d/99-local-config.ini'
  355. owner: 'root'
  356. group: 'root'
  357. mode: '0644'
  358. when: with_fpm|bool and ansible_lsb.major_release|int >= 9
  359. tags:
  360. - 'web'
  361. - 'php'
  362. - name: 'Install Apache2 config files for PHP FPM'
  363. template:
  364. src: 'fpm/apache2/fpm-pool.conf.j2'
  365. dest: '/etc/apache2/conf-available/fpm-pool.conf'
  366. owner: 'root'
  367. group: 'root'
  368. mode: '0644'
  369. when: with_fpm|bool and with_apache2|bool
  370. tags:
  371. - 'web'
  372. - 'php'
  373. - name: 'Install Nginx config files for PHP FPM (fpm servers pool)'
  374. template:
  375. src: 'fpm/nginx/fpm-pool.conf.j2'
  376. dest: '/etc/nginx/conf.d/fpm-pool.conf'
  377. owner: 'root'
  378. group: 'root'
  379. mode: '0644'
  380. notify:
  381. - 'Reload nginx'
  382. when: with_fpm|bool and with_nginx|bool
  383. tags:
  384. - 'web'
  385. - 'php'
  386. - name: 'Install Nginx config files for PHP FPM (fpm fastcgi config)'
  387. template:
  388. src: 'fpm/nginx/fastcgi_pass_fpm.j2'
  389. dest: '/etc/nginx/fastcgi_pass_fpm'
  390. owner: 'root'
  391. group: 'root'
  392. mode: '0644'
  393. notify:
  394. - 'Reload nginx'
  395. when: with_fpm|bool and with_nginx|bool
  396. tags:
  397. - 'web'
  398. - 'php'
  399. - name: 'Ensure FPM for PHP 5 is running (Debian <= 8)'
  400. service:
  401. name: 'php5-fpm'
  402. state: 'started'
  403. when: with_fpm|bool and ansible_lsb.major_release|int <= 8
  404. tags:
  405. - 'web'
  406. - 'php'
  407. - name: 'Ensure FPM for PHP {{ php_version }} is running (Debian >= 9)'
  408. service:
  409. name: 'php{{ php_version }}-fpm'
  410. state: 'started'
  411. when: with_fpm|bool and ansible_lsb.major_release|int >= 9
  412. tags:
  413. - 'web'
  414. - 'php'
  415. # vim: ft=yaml.ansible