What is VVV?
I have been using Varying Vagrant Vagrants (VVV) for some time now as my development environment for WordPress projects. If you haven’t used VVV, I encourage you to try it out, it makes a lot of things easier in terms of setting up your local server. VVV’s primary use is for the development of WordPress itself but the Auto Site Setup feature allows you to use VVV for developing your own WordPress projects.
This guide assumes familiarity with VVV and the Auto Site Setup feature, so please check out the VVV documentation before proceeding.
Can I use VVV for Drupal development?
This past month, I’ve had to work on a couple of Drupal projects and I ended up using the WordPress VVV environment for them. The auto site setup is very similar to what you would normally do with WordPress projects with a couple of tweaks which I’ll go through below.
Different vvv-nginx.conf file
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 |
server { listen 80; server_name vvv-my-drupal-project.dev; root {vvv_path_to_folder}/public; location / { index index.php index.html; try_files $uri $uri/ /index.php?$args; } charset utf-8; gzip off; location ~ \.php$ { # Try the files specified in order. In our case, try the requested URI and if # that fails, try (successfully) to pass a 404 error. try_files $uri =404; # Include the fastcgi_params defaults provided by nginx include /etc/nginx/fastcgi_params; # The amount of time for upstream to wait for a fastcgi process to send data. # We keep this *extremely* high so that one can be lazy when remote debugging. fastcgi_read_timeout 3600s; # Buffer size for reading the header of the backend FastCGI process. # This defaults to the value of a single fastcgi_buffers, so does not # need to be specified in our case, but it's good to be explicit. fastcgi_buffer_size 128k; # The number and size of the buffers into which the reply from the FastCGI # process in the backend is read. # # 4 buffers at 128k means that any reply by FastCGI greater than 512k goes # to disk and replies under 512k are handled directly in memory. fastcgi_buffers 4 128k; # SCRIPT_FILENAME is a required parameter for things to work properly, # but was missing in the default fastcgi_params on upgrade to nginx 1.4. # We define it here to be sure that it exists. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Use the upstream for php5-fpm that we defined in nginx.conf fastcgi_pass php; # And get to serving the file! fastcgi_index index.php; } } |
In your vvv-nginx.conf, instead of including /etc/nginx/nginx-wp-common.conf;
which has WordPress centric configurations, use the above which is a stripped down version of /etc/nginx/nginx-wp-common.conf;
.
Install Drush
VVV comes pre-configured with WP-CLI. If you’re developing with Drupal, you are probably going to want to use Drush. Instead of messing with the VVV box, you can install Drush just for your Drupal project. Create a composer.json* file for your project with the following lines:
1 2 3 4 5 6 7 8 9 |
{ "name": "my-company/my-drupal-project", "description": "My Drupal Project", "license": "proprietary", "require": { "drush/drush": "7.*" } } |
And so that you can easily set up Drush again for your next Drupal project, we’re going to use a Makefile to handle the installation:
1 2 3 4 5 6 |
install-composer: test -f composer.phar || \ curl -sS https://getcomposer.org/installer | php install-drush: install-composer php composer.phar install |
With the Makefile in place, cd
into your project folder and run make install-drush
. This will install drush within your project.
Using drush
Now that you’ve got Drush installed, let’s add another Makefile target that will make it easy to use.
1 2 3 4 5 |
project_path = /vagrant/www/vvv-projects/my-drupal-project/public drush_path = /vagrant/www/vvv-projects/my-drupal-project/vendor/drush/drush/ vvv-drush: vagrant ssh -c 'export PATH="$(drush_path):$$PATH" && cd $(project_path) && drush $(args)'; |
We’re now ready to use Drush. From your local machine, try make vvv-drush args='cc all'
(replace cc all
with the Drush command you’d like to run.
With these two tweaks in place, you’re good to go for using VVV for developing your Drupal project.
* Composer is a dependency manager for PHP.