What do you need to enjoy web-development with Drupal? You need a comfortable workspace to make all your ideas come true! Let’s come up with some criteria of a perfect workspace that would fit any web developer:
1. You shouldn’t be limited by your operational system
2. Your development website has to be fast
You’re not a system administrator and you prerfer to use all-in-one web-server solutions like openserver, xampp and denwer. But they are extremely slow. Even new just installed Drupal website would be slow! No problem, you don’t have to be a guru to have the best speed server. We will show you.
3. Production and development/testing environments have to be similar
You know how painful it is when your application fails to run on production though it worked great on your local pc and passed all the tests. We will make all environments similar. Even if there are too many of them. Let’s solve it.
To solve all stated problems we will use following technologies/utilites
1. Virtualbox. Yes, virtual machines are what you need. You might have used one of them before, at least you heard about them. Now we will use it really tight. Download and install it.
2. Vagrant + Chef. This is the core of the solution. Vagrant allows you to create and manipulate as many virtualboxes as you need with simple commands. Chef configures your virtual machine according to predefined cookbooks. There are really a lot of cookbooks in the web, so you don’t have to be an experienced web developer to install linux + nginx + mysql + php. It’s all there, in cookbooks. You only need to include appropriate cookbooks to your vagrant configuration file.
Download and install vagrant (chef will be there)
3. Now we are ready to run our first virtual box. To make it easier for you just download ADCI Solutions pre-configured vagrant repo
Then you should run your OS command line and run ‘vagrant up’ command inside vagrant repo folder.
Now you have a virtual machine with:
- Ubuntu 13.04
- Configured Nginx + mysql + php server
- Git, drush, phing and CodeSniffer installed
- If you need anything else, just find an appropriate cookbook and use it!
And yes, you can use the same Chef configuration for production environment. Don’t forget to show it to your testers too.
Let’s run the website now!
You can log in to your virtual machine by ssh using ‘vagrant ssh’ command inside vagrand repo folder.
If you prefer to use another ssh client, you can get the ssh connection data with 'vagrant ssh-config' command.
Now place your site to /var/www/site/project directory (as example, we have placed there index.php file with ‘<?php phpinfo(); ?>’ line) and run 127.0.0.1:4567 in your browser inside host OS. You should see your website now (if not, try ‘sudo service nginx restart’ inside virtual machine to be sure your server is running’).
That’s it. After running and configuring sftp you’ll be able to access your files in a dedicated drive. So you can develop on host OS with any IDE you like though it will be run on virtual machine. And now you have that powerful linux command line and tools which make everyting work like a charm.
Good luck and enjoy your advanced dream workspace!