Using Laravel Valet with Drupal multiple sites

Setup of development environment for Mac is made easy with Laravel Valet. Comparing it with XAMPP setup, we don't need to edit hosts file and httpd.conf/httpd-vhosts.conf Apache configuration files to add a local development domain. Even Drupal multiple sites setup (sharing the same code base) is possible in Laravel Valet. In this article will discuss the Drupal multiple sites setup step by step guide and we will use local development domain http://webfoobar.test as Drupal site #1 and http://drupal.test as Drupal site #2.


  1. Install Homebrew. Execute the following shell command in your terminal:

    /usr/bin/ruby -e "$(curl -fsSL"

    Note: If you have Homebrew already installed, update it:

    brew update
  2. Install PHP 7.1. Execute the following shell command in your terminal:

    brew install homebrew/php71
  3. Install MariaDB (an enhanced, drop-in replacement for MySQL). Execute the following shell commands in your terminal:

    brew install mariadb
    brew services start mariadb

    To setup phpMyAdmin, follow this article: Setup phpMyAdmin with Laravel Valet.

  4. Install composer. Execute the following shell commands in your terminal:

    php -r "copy('', 'composer-setup.php');"
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"

    Reference: Composer Command-line installation

  5. Move/rename the executable composer script to /usr/local/bin/ so that we can execute it anywhere and as plain "composer" (without the .phar):

    mv ~/composer.phar /usr/local/bin/composer
  6. Now lets install Laravel Valet using composer:

    composer global require laravel/valet
    valet install
  7. Create two databases for the two development sites (http://webfoobar.test and http://drupal.test).

  8. Go to your Drupal site directory and append the following codes in sites/sites.php file:

    $sites['webfoobar.test'] = '';
    $sites['drupal.test'] = '';

    Execute the following shell commands in your terminal:

    mkdir sites/ sites/
    cp sites/default/default.settings.php sites/
    cp sites/default/default.settings.php sites/
    chmod 644 sites/ sites/
  9. Still in your Drupal site directory, execute the following shell commands in your terminal:

    valet domain test
    valet link webfoobar
    valet link drupal

    Now we can access our two different Drupal sites in our favorite browser by going to http://webfoobar.test and http://drupal.test local development domains. Go to http://webfoobar.test/install.php and http://drupal.test/install.php to begin the Drupal installation.

    Note: if you want a different TLD for example ".loc" instead of ".test", just execute:

    valet domain loc

    The local development domains will become http://webfoobar.loc and http://drupal.loc. Don't forget to register these changes at sites/sites.php Drupal configuration file:

    $sites['webfoobar.loc'] = '';
    $sites['drupal.loc'] = '';


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.