php.yml 4.4 KB

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