/vagrant-ansible-lamp

LAMP Stack provisioned using Ansible on Vagrant

Primary LanguageShellMIT LicenseMIT

LAMP Stack via Ansible on Vagrant

Build Status

Setup LAMP Stack with RHEL/CentOS or Debian/Ubuntu using Ansible as provisioner on Vagrant

Requirements

  1. Make sure your machine supports Virtualization
  2. VirtualBox installed - get it from https://www.virtualbox.org/wiki/Downloads
  3. Vagrant installed - get it from http://www.vagrantup.com/downloads.html

Provisioning

Vagrant uses ansible local provisioning so it should work fine on Windows and Linux where no ansible is installed on the host machine.

LAMP

Linux

These are a few of the distros that works out of the box. Other versions under the RHEL/Debian family should work with minimal changes to the configurations.

  • Ubuntu 14.04 (Trusty)
  • Centos 6.8

Related config

You can change the type of distribution you want by updating the config.vm.box part of the Vagrantfile.

config.vm.box = 'geerlingguy/centos6'

Apache

See ansible-role-apache for more info on Apache.

Related config

You can update the VirtualHost's servername and alias by editing vars/main.yml

apache_vhosts:
  - servername: "local.dev"
    serveralias: "local.dev"
    documentroot: "/var/www/vagrant/html"

MySQL

See ansible-role-mysql for more info on MySQL.

Related config

Below are some of the variables specific to MySQL

# vars/main.yml
mysql_root_password: root
mysql_databases:
  - name: sample_db
    encoding: latin1
    collation: latin1_general_ci
mysql_users:
  - name: vagrant
    host: "%"
    password: vagrant
    priv: "sample_db.*:ALL"
mysql_enabled_on_startup: yes

PHP

See ansible-role-php for more info on PHP.

Related config

Below are some of the variables specific to PHP

# vars/main.yml
php_enablerepo: "epel"
php_opcache_enable: "0"
php_enable_apc: false
# vars/RedHat.yml
php_packages:
  - php56w
  - php56w-cli
  - php56w-common
  - php56w-dom
  - php56w-gd
  - php56w-mysql
# vars/Debian.yml
php_packages:
  - libapache2-mod-php5.6
  - php5.6
  - php5.6-cli
  - php5.6-common
  - php5.6-dom
  - php5.6-gd
  - php5.6-mysql

Document Root

The folder html is where you should place your PHP project. It is mapped to /var/www/vagrant/html directory of the VM and is being used by a VirtualHost with a servername local.dev.

Hosts Resolution

In order for your project to be accessible, you need to edit your hosts file and add the following:

127.0.0.1 local.dev

Windows

For Windows host machine, you can edit your hosts file by doing the ff:

  1. Run cmd as administrator
  • Search for cmd in start menu > right click > run as administrator
  1. Once in cmd, enter the ff: notepad drivers\etc\hosts
  2. Add the lines above and save

Linux

For Linux host machine, you can edit your hosts file by doing the ff:

  1. Launch terminal
  2. Once in terminal, enter the ff: sudo vi /etc/hosts
  3. Add the lines above and save

Once you've updated your hosts file, you can now access your project at http://local.dev:8080

Ansible Roles

License

MIT