Skip to content

Sites Configuration

mcuyar edited this page Nov 20, 2014 · 7 revisions

Sites can be setup and configured from your custom config.yaml file. Let's start with a basic site creation setup with laravel.

The Sites module follows the default homestead syntax, but adds additional features and modules.

Add this to your config file to create a new laravel app:

sites:
  - map: laravel.dev
    to: /var/www/laravel/public
    hhvm: true
    git-clone:
      name: api
      url: "--depth 1 --branch v4.2.11 https://github.com/laravel/laravel.git"
      path: /var/www/laravel
    commands:
      install:
        - 'rm -rf .git'
        - "git init && git add -A && git commmit -m 'Initial Commit'"
        - 'composer install --prefer-dist'
      update:
        - 'composer update'
    db:
      type: postgresql
      name: laravel
      user: happy
      password: nachos
    variables:
      DB_NAME: laravel
      DB_USER: happy
      DB_PASSWORD: nachos
      AWS_ACCESS_KEY: aws_access_key
      AWS_SECRET_KEY: aws_secret_key
    xdebug:
      idekey: laravel
    git-config:
      user.email: matt@exaple.com

Mapping

The parameters will map a specific domain to a folder on the server.

map: laravel.dev
to: /var/www/laravel/public

HHVM

You can run your site using HHVM by simply passing true to the hhvm parameter

hhvm: true

Cloning a git repository

You can clone a git repository and set a custom path for its installation.

git-clone:
  name: api
  url: "--depth 1 --branch v4.2.11 https://github.com/laravel/laravel.git"
  path: /var/www/laravel

Note: A site cannot be cloned into an existing directory.

Note: you can pass git clone parameters to the url config parameter.

Adding an install command (only for git clone)

Because we are cloning laravel, we don't want to keep it's history. Let's run an install command to remove the git folder, create a new git repository with it's first git commit and run a composer install.

commands:
  install:
    - 'rm -rf .git'
    - "git init && git add -A && git commmit -m 'Initial Commit'"
    - 'composer install --prefer-dist'

Note: Commands run as vagrant from the install directory

Creating a site database with user and password

As well as creating databases globally, you can create a database with user and password for a specific site. user and password are optional parameters and will default to user: homestead and password: secret.

db:
  type: postgresql #mysql or postgresql
  name: laravel
  user: happy
  password: nachos

Adding environment variable for a site

variables:
    DB_NAME: laravel
    DB_USER: happy
    DB_PASSWORD: nachos
    AWS_ACCESS_KEY: aws_access_key
    AWS_SECRET_KEY: aws_secret_key

Setting an xdebug ide key

If you are using the xdebug feature, you can set the key to listen for in

xdebug:
  idekey: laravel

Adding local git config variables

You can configure git config variables locally for a version controlled site.

git-config:
    user.email: matt@example.com