Here’s a README.md file that I’ve developed over time. It explains how I setup and use Valet+ for quick and powerful Drupal development.
Sorry for the formatting. I’ll get markdown support on my blog sometime…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# Initial Valet Setup 1. Install or update Homebrew to the latest version using brew update 2. Install PHP 7.0 using Homebrew via `brew install php70` This PHP version is just to get Valet working; Valet will auto-download other php versions if you use `valet use N.N` to switch versions. 3. Install Composer using Homebrew via `brew install homebrew/php/composer` 4. Install Valet+ with Composer via `composer global require weprovide/valet-plus` 5. Add export PATH="$PATH:$HOME/.composer/vendor/bin" to shell profile (`~/.bash_profile` typically) For Fish add `set -gx PATH /Users/adam/.composer/vendor/bin $PATH` to `~/.config/fish/config.fish` 6. Run the `valet install` command. Optionally add `--with-mariadb` to use MariaDB instead of MySQL This will configure and install Valet+ and DnsMasq, and register Valet's daemon to launch when your system starts. 7. Once Valet+ is installed, try pinging any .test domain on your terminal. e.g., `ping foobar.test`. If Valet+ is installed correctly you should see this domain responding on 127.0.0.1. If not you might have to restart your system. Especially when coming from the Dinghy (docker) solution. 8. Make a folder to store your sites `mkdir ~/valet` Do not `valet park`. See notes below. See https://github.com/weprovide/valet-plus#installation for additional installation notes # Site Setup (serving from ~/valet/[sitename]/docroot) 1. Create site directory via `mkdir ~/valet/mysite` 2. Move into it via `cd mysite` 3. Use rsync/git/composer/whatever to acquire your site files -- e.g., `git clone git@bitbucket.org:mysite.git .` 4. Move into docroot via `cd docroot` 5. Tell valet to serve a site from this folder via `valet link mysite` 6. Browse to `http://mysite.test` -- if you get a DB error, that's okay for now. 7. Create a new database via `valet db create mysite` 8. Existing site? Import the data with `valet db import ~/db_snapshots/mysite.sql.gz mysite` 9. Update the db credentials in `sites/default/settings.local.php` -- database=mysite, username=root, password=root 10. Browse to `http://mysite.test` -- hopefully it _just works_ ---- # Explanation of Serving Sites from Docroot Subdirectories Don't `valet park` in this `~/valet` directory. You can do it somewhere else if you need auto-folder-to-domain functionality where you create a folder and it results in having `http://folder.test` available immediately. For this `~/valet` directory we have sites that have `/docroot` subdirectories containing the actual site files, so instead of `park`, use `valet link [sitename]` from the docroot directory. This will create symlinks in `~/.valet/Sites` which will be accessible at `http://sitename.test` # Other Tips - RTFM! Valet does some amazing things. Read the docs to learn about xdebug, logging sharing, redis, mailhog, etc. - `valet links` to view current links - `valet unlink [sitename]` to remove a link - `valet use 5.6` to change php version (5.6 7.0 7.1 7.2) - Edit `~/.valet/config.json` to set domain suffix (`.test` is default) (`valet restart` after) - Edit `~/.valet/Drivers/` to setup new drivers (shouldn't need to) (`valet restart` after maybe?) - `valet share` to share your site over the internet Hit CTRL-C to stop sharing - You may not have a `$_SERVER['DOCUMENT_ROOT']` value. Until I have time to look into this, I'm just setting that at the top of my Drupal `settings.local.php` file. ``` // Manually set because Valet+ doesn't, for some reason $_SERVER['DOCUMENT_ROOT'] = '/Users/adam/valet/mysite/docroot'; ``` - Install and enable memcached with: `brew install php71-memcached && valet restart` - Configure php with ini files at, for example, `/usr/local/etc/php/7.1/php.ini` - To generate nginx file specific to site you can: - Generate config file by securing the site: `valet secure mysite` - Copy the nginx config code in the resulting nginx file at `~/.valet/Nginx/mysite.test` - Stop here if you want to keep SSL... otherwise: - Use `valet unsecure mysite` to remove SSL (if you don't want the site served over 443) - Re-create `~/.valet/Nginx/mysite.test` with the copied code - Rework config file to serve port 80 without any SSL certs attached - To fix `upstream sent too big header while reading response header from upstream` error: - Add these lines to your `~/.valet/Nginx/mysite.test`: - `fastcgi_buffers 16 16k;` - `fastcgi_buffer_size 32k;` - NOTE: Add these to the `location ~ \.php$ {` section if you have a full nginx conf file - To fix `504 Gateway Timeout` error: - Add these lines to your `~/.valet/Nginx/mysite.test`: - `fastcgi_buffers 16 16k;` - `fastcgi_buffer_size 32k;` - `fastcgi_read_timeout 180;` - NOTE: Add these to the `location ~ \.php$ {` section if you have a full nginx conf file # Links Valet+ Docs https://github.com/weprovide/valet-plus Parking and Linking https://laravel.com/docs/5.5/valet#serving-sites |
Leave a Reply