Valet+ Quickstart for Drupal Development
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# Initial Valet Setup Follow official install guide at https://github.com/weprovide/valet-plus # Installation The following procedure is what it took to get Valet+ installed correctly on my Macbook. I had issues with MySQL not starting. # Install Valet brew update brew tap henkrehorst/php brew install valet-php@7.2 brew install composer brew link --overwrite composer brew install php@7.1 composer global require weprovide/valet-plus vim ~/.bash_profile valet fix valet install # Link an app cd ~/valet/mysite/docroot/ valet link mysite valet restart # Create a database valet db create mysite (COMMAND FAILED; MYSQL NOT RUNNING?) valet stop # Fix MySQL brew uninstall mysql brew uninstall mysql@5.7 brew cleanup rm -rf /usr/local/var/mysql rm /usr/local/etc/my.cnf brew install mysql@5.7 brew link --force mysql@5.7 brew services start mysql@5.7 valet fix valet install # Create a database valet start valet db create mysite # SUCCESS! ---- Tips: - Make a folder to store your sites `mkdir ~/valet` - Do not `valet park`. See notes below. # 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`. If this fails, see top of this doc! 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/Web 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 |