php.yml 4.6 KB

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