Skip to content

Instantly share code, notes, and snippets.

@aeosys
Last active July 9, 2017 17:14
Show Gist options
  • Save aeosys/9ea58d042b13ae12e07a1c993d1832b4 to your computer and use it in GitHub Desktop.
Save aeosys/9ea58d042b13ae12e07a1c993d1832b4 to your computer and use it in GitHub Desktop.
PHP7 dev server for Symfony
---
- hosts: all
become: true
tasks:
- name: Ensure apt has updated cache
apt: update_cache=yes
- name: Install https transport
apt:
name: apt-transport-https
state: present
- apt_key:
url: https://www.dotdeb.org/dotdeb.gpg
state: present
- apt_repository: repo={{ item }} state=present update_cache=yes
with_items:
- deb https://packages.sury.org/php/ jessie main
- name: Install packages
apt: name={{ item }} state=latest
with_items:
- git
- apache2
- mariadb-server
- python-mysqldb
# Apache
- name: Enabled mod_rewrite
apache2_module: name=rewrite state=present
notify:
- restart apache2
- name: Move Apache configuration to quest
copy: src=symfony.apache.conf dest=/etc/apache2/sites-available/symfony.conf
- name: Apply Apache configuration
command: a2ensite symfony
args:
creates: /etc/apache2/sites-enabled/symfony.conf
notify:
- restart apache2
- name: Disable default Apache configuration
command: a2dissite 000-default
args:
removes: /etc/apache2/sites-enabled/000-default.conf
notify:
- restart apache2
- name: Create db for symfony
mysql_db: name=symfony state=present
- name: Link www to home folder
file: src=/home/vagrant/site path=/var/www/symfony state=link force=yes
# PHP
- name: Install PHP7.1
apt: name={{ item }} state=latest allow_unauthenticated=yes
with_items:
- php7.1
- php7.1-bz2
- php7.1-curl
- php7.1-cli
- php7.1-dba
- php7.1-imap
- php7.1-intl
- php7.1-json
- php7.1-mbstring
- php7.1-mcrypt
- php7.1-mysql
- php7.1-odbc
- php7.1-soap
- php7.1-xml
- php7.1-zip
handlers:
- name: restart apache2
service: name=apache2 state=restarted
<VirtualHost *:80>
ServerName devel.tld
ServerAlias www.devel.tld
DocumentRoot /var/www/symfony/web
<Directory /var/www/symfony/web>
AllowOverride None
Require all granted
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
# Authentication headers
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
<Directory /var/www/symfony>
Options FollowSymlinks
</Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/symfony/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/symfony_error.log
CustomLog /var/log/apache2/symfony_access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment