Code Monkey home page Code Monkey logo

ansible-php-site-role's Introduction

Ansible PHP Site Role

Build Status

This Ansible role will install a given version of PHP on your server and set up a site in Nginx running PHP. The role uses Phpenv to manage the different versions of PHP. It should be able to install any version of PHP from 5.2 through 7.0 (although if you're installing PHP 5.2, you may need to seriously rethink your life choices ;-).

Requirements

Phpenv requires Git to be installed on your server, but then what server doesn't have Git these days?

This role takes advantage of Linux filesystem ACLs and a group called "web-admin" for granting access to particular directories. You can either configure those steps manually or install the bbatsche.Base role.

Role Variables

  • domain — Site domain to be created
  • dynamic_php — Whether or not Nginx should rewrite all requests on your site through index.php. This is used for most modern frameworks. Default is no
  • max_upload_size — Maximum upload size in MB. Default is "10"
  • timezone — Timezone that should be configured in PHP. Default is "Etc/UTC"
  • mysql_socket — Path to default MySQL socket for use when connecting to localhost. Default is "/var/run/mysqld/mysqld.sock"
  • php_version — Version of PHP to install with Phpenv. If this value is omitted, the OS default version will be used instead (5.5 for Ubuntu 14.04)
  • pecl_extensions — A list of additional extension to install from PECL. Each value should have a name and a version
  • composer_packages — A list of composer packages to install. Each value should have a name and a version property.
  • phpenv_version — Version of Phpenv to install. Default is a Git SHA: "b003acc"
  • phpenv_composer_version — Version of Phpenv Composer Plugin to install. Default is a Git SHA: "1a6611d"
  • phpenv_build_version — Version of PHP Build to install. Default is a Git SHA: "876560b"
  • xdebug_version — Version of Xdebug to install
  • copy_phpinfo — Whether to copy a phpinfo() page to the new site. Default is no
  • copy_index_php — Whether to copy an index.php stub file to the new site. Default is no
  • disabled_function — A list of functions to disable when PHP is running from the web. The default value blocks functions that could be used to execute shell code or manipulate other processes on the server.
  • http_root — Directory all sites will be created under. Default is "/srv/http"
  • phpenv_root — Where to install Phpenv and its support files. Default is "/usr/local/phpenv"

Dependencies

This role depends on bbatsche.Nginx. You must install that role first using:

ansible-galaxy install bbatsche.Nginx

Example Playbook

- hosts: servers
  roles:
  - role: bbatsche.Phpenv
    domain: my-php-site.dev
    php_version: 5.6.19
    xdebug_version: 2.4.0
    phpunit_version: ~5.2
    pecl_extensions:
    - name: yaml
      version: 1.2.0
    - name: imagick
      version: 3.4.0

License

MIT

Testing

Included with this role is a set of specs for testing each task individually or as a whole. To run these tests you will first need to have Vagrant and VirtualBox installed. The spec files are written using Serverspec so you will need Ruby and Bundler. Note: To keep things nicely encapsulated, everything is run through rake, including Vagrant itself. Because of this, your version of bundler must match Vagrant's version requirements. As of this writing (Vagrant version 1.8.1) that means your version of bundler must be between 1.5.2 and 1.10.6.

To run the full suite of specs:

$ gem install bundler -v 1.10.6
$ bundle install
$ rake

To see the available rake tasks (and specs):

$ rake -T

There are several rake tasks for interacting with the test environment, including:

  • rake vagrant:up — Boot the test environment (Note: This will not run any provisioning tasks.)
  • rake vagrant:provision — Provision the test environment
  • rake vagrant:destroy — Destroy the test environment
  • rake vagrant[cmd] — Run some arbitrary Vagrant command in the test environment. For example, to log in to the test environment run: rake vagrant[ssh]

These specs are not meant to test for idempotence. They are meant to check that the specified tasks perform their expected steps. Idempotency can be tested independently as a form of integration testing.

ansible-php-site-role's People

Contributors

bbatsche avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.