Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Fixes #921: Switch to mainline PHP 5.6 PPA on Ubuntu.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Oct 12, 2016
1 parent 23306c8 commit 91f6d97
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 56 deletions.
51 changes: 28 additions & 23 deletions docs/other/php-56.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,48 @@ Ondřej Surý's PPA for PHP 7.0 is used to install PHP 7, but you can switch to
```yaml
vagrant_box: geerlingguy/ubuntu1404
php_version: "5.6"
php_install_recommends: no
php_version: "5.6"
php_install_recommends: no
php_packages:
- php5
- php5-apcu
- php5-mcrypt
- php5-cli
- php5-common
- php5-curl
- php5-dev
- php5-fpm
- php5-gd
- php5-sqlite
- php5.6
- php5.6-apcu
- php5.6-mcrypt
- php5.6-cli
- php5.6-common
- php5.6-curl
- php5.6-dev
- php5.6-fpm
- php5.6-gd
- php5.6-sqlite3
- php5.6-xml
- php5.6-mbstring
- php-pear
- libpcre3-dev
php_conf_paths:
- /etc/php5/fpm
- /etc/php5/apache2
- /etc/php5/cli
- /etc/php/5.6/fpm
- /etc/php/5.6/apache2
- /etc/php/5.6/cli
php_extension_conf_paths:
- /etc/php5/fpm/conf.d
- /etc/php5/apache2/conf.d
- /etc/php5/cli/conf.d
php_fpm_daemon: php5-fpm
php_fpm_conf_path: "/etc/php5/fpm"
php_fpm_pool_conf_path: "/etc/php5/fpm/pool.d/www.conf"
php_mysql_package: php5-mysql
- /etc/php/5.6/fpm/conf.d
- /etc/php/5.6/apache2/conf.d
- /etc/php/5.6/cli/conf.d
php_fpm_daemon: php5.6-fpm
php_fpm_conf_path: "/etc/php/5.6/fpm"
php_fpm_pool_conf_path: "/etc/php/5.6/fpm/pool.d/www.conf"
php_mysql_package: php5.6-mysql
```
If you're using Apache with `mod_php` you should also add `libapache2-mod-php5` to the `php_packages` list.
If you're using Apache with `mod_php` you should also add `libapache2-mod-php5.6` to the `php_packages` list.

Also, if you're using one of the `installed_extras`, you may need to update the package names accordingly:

```yaml
# If you install `redis`:
php_redis_package: php5-redis
php_redis_package: php5.6-redis

# If you install `memcached`:
php_memcached_package: php5-memcached
php_memcached_package: php5.6-memcached

# If you install `xhprof`:
xhprof_download_url: https://github.com/phacility/xhprof/archive/master.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
- src: geerlingguy.nodejs
version: 3.3.0
- src: geerlingguy.php
version: 3.3.0
version: 3.3.2
- src: geerlingguy.php-memcached
version: 2.0.0
- src: geerlingguy.php-mysql
Expand Down
36 changes: 17 additions & 19 deletions provisioning/roles/geerlingguy.php/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sudo: required
services: docker

env:
# Test package install on all supported OSes.
Expand All @@ -8,6 +8,11 @@ env:
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
php_version: 7.0
- distro: fedora24
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
php_version: 5.6
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
Expand Down Expand Up @@ -36,49 +41,42 @@ env:
playbook: test-source.yml
php_version: 7.0.5

services:
- docker

before_install:
# Pull container.
- 'sudo docker pull geerlingguy/docker-${distro}-ansible:latest'
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'

script:
- container_id=$(mktemp)
# Run container in detached state.
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'

# Install dependencies.
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'

# Ansible syntax check.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'

# Test role.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}'

# Test role idempotence.
- idempotence=$(mktemp)
- sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} | tee -a ${idempotence}
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} | tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Ensure PHP is installed and at the right version.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm which php'
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm test -x /usr/bin/php'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which php'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm test -x /usr/bin/php'

- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm php --version'
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm /usr/bin/php --version | grep -qF "PHP ${php_version}"'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm php --version'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm /usr/bin/php --version | grep -qF "PHP ${php_version}"'

# Ensure PHP configurations have taken effect.
- sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm php -i | grep 'memory_limit.*192'

after_success:
# Clean up.
- 'sudo docker stop "$(cat ${container_id})"'
- docker exec --tty "$(cat ${container_id})" env TERM=xterm php -i | grep 'memory_limit.*192'

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4 changes: 4 additions & 0 deletions provisioning/roles/geerlingguy.php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ The default values for the HTTP server deamon are `httpd` (used by Apache) for R

If you have enabled any additional repositories such as [geerlingguy.repo-epel](https://github.com/geerlingguy/ansible-role-repo-epel) or [geerlingguy.repo-remi](https://github.com/geerlingguy/ansible-role-repo-remi), you may want an easy way to swap PHP versions on the fly. By default, this is set to 'installed'. You can now override this variable to 'latest'. Combined with php_enablerepo, a user now doesn't need to manually uninstall the existing PHP packages before installing them from a different repository.

php_install_recommends: yes

(Debian/Ubuntu only) Whether to install recommended packages when installing `php_packages`; you might want to set this to `no` explicitly if you're installing a PPA that recommends certain packages you don't want (e.g. Ondrej's `php` PPA will install `php7.0-cli` if you install `php-pear` alongside `php5.6-cli`... which is often not desired!).

php_executable: "php"

The executable to run when calling PHP from the command line. You should only change this if running `php` on your server doesn't target the correct executable, or if you're using software collections on RHEL/CentOS and need to target a different version of PHP.
Expand Down
3 changes: 3 additions & 0 deletions provisioning/roles/geerlingguy.php/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ php_enablerepo: ""
# you want to upgrade or switch versions using a new repo.
php_packages_state: installed

# Whether to install recommended packages. Used only for Debian/Ubuntu.
php_install_recommends: yes

# Set this to false if you're not using PHP with Apache/Nginx/etc.
php_enable_webserver: true

Expand Down
1 change: 1 addition & 0 deletions provisioning/roles/geerlingguy.php/tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
apt:
name: "{{ item }}"
state: "{{ php_packages_state }}"
install_recommends: "{{ php_install_recommends }}"
with_items: "{{ php_packages }}"
register: php_package_install
notify: restart webserver
Expand Down
6 changes: 3 additions & 3 deletions provisioning/roles/geerlingguy.php/tests/test-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
php_memory_limit: "192M"

pre_tasks:
- name: Ensure build dependencies are installed (RedHat).
package: name=which state=present
when: ansible_os_family == 'RedHat'
- name: Update apt cache.
apt: update_cache=yes
when: ansible_os_family == 'Debian'

roles:
- geerlingguy.git
Expand Down
8 changes: 4 additions & 4 deletions provisioning/roles/geerlingguy.php/tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
php_enablerepo: "remi,remi-php70"

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes
when: ansible_os_family == 'Debian'

- include_vars: test-vars-ubuntu1204.yml
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '12.04'

- name: Ensure build dependencies are installed (RedHat).
package: name=which state=present
when: ansible_os_family == 'RedHat'

- name: Add repository for PHP 7.
apt_repository: repo='ppa:ondrej/php'
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version != '12.04'
Expand Down
11 changes: 5 additions & 6 deletions provisioning/tasks/init-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
apt_repository: repo='ppa:ondrej/php5'
when: php_version == "5.5" and ansible_distribution == "Ubuntu" and ansible_distribution_version == "12.04"

- name: Add repository for PHP 5.6.
apt_repository: repo='ppa:ondrej/php5-5.6'
when: php_version == "5.6" and ansible_distribution == "Ubuntu" and ansible_distribution_version != "16.04"

- name: Add repository for PHP 7.0.
- name: Add repository for PHP 5.6 or 7.0.
apt_repository: repo='ppa:ondrej/php'
when: php_version == "7.0" and ansible_distribution == "Ubuntu" and ansible_distribution_version != "16.04"
when: >
(php_version == "5.6" or php_version == "7.0") and
ansible_distribution == "Ubuntu" and
ansible_distribution_version != "16.04"
- name: Define php_xhprof_html_dir.
set_fact:
Expand Down

0 comments on commit 91f6d97

Please sign in to comment.