Today we're announcing a new release to Scotch Box. If you don't know what Scotch Box is, it's a prepackaged Vagrant box with a ton of LAMP stack features. It exists solely to make Vagrant dead-simple, remove overhead with setting up a PHP stack, and so you don't have to worry about Vagrant breaking all the time.
Scotch Box is a free thing we support and host for the dev community. It currently has 340,000+ downloads and is ranked #9 on the most downloaded Vagrant boxes of all time.
First, some links for reference:
Table of Contents
The newest updates include:
- General OS updates
- Laravel Tutorial
- WordPress Tutorial
- MongoDB has been added
- MongoDB PHP extension is added
- Opcache is disabled
- Node is updated 5.x
- Updates to NPM packages (Bower, Gulp, Yeoman, Browser-Sync, PM2)
- Composer is updated
- Composer is finally added to Path
- Laravel executable works out-of-the-box
- Improvements to PHP MySQL issues
- WP-CLI has been added per request
- Mailcatcher is added to test emails finally
- Created an Update Policy
Upgrading Scotch Box is super easy. Just run
vagrant box update
Debugging the Update
So, Vagrant has this really annoying bug with packaging boxes via
vagrant package. We were able to work around this, but if you run into issues, here's some things to try.
Update your OS
Update to Windows to version 10 or Mac OS to El Captain.
Update Vagrant to 1.7.4
You can update Vagrant easily here.
Update Virtual Box to 5.0.x
You can update Virtual Box by visiting their download page. Make sure you download the latest version and its extension pack.
If you're getting weird authentication issues, you can manually override this by adding this to your Vagrantfile.
config.ssh.username = "vagrant" config.ssh.password = "vagrant"
MongoDB has been added to Scotch Box by default. Robomongo is an awesome Mac client to test this with. You can do SSH tunneling like so:
SSH Address: 192.168.33.10 Port: 22 SSH Username: vagrant SSH Password: vagrant Mongo Host: localhost Mongo Port: 27017 Mongo DB: scotchbox
With PHP, you can connect like this:
$db = new MongoClient('mongodb://localhost'); $dbs = $db->listDBs(); var_dump($dbs);
And, from the mongo Shell, just run:
# SSH into Vagrant box vagrant ssh # Test it's working service mongod status # Woo, it's working. Let's connect mongo use scotchbox
Node.js recently merged with IO.js. We've updated to Node 5.0. We've also updated all global NPM packages.
Even though these are packaged into the Vagrant box, we always recommend running node and any packages from your local machine and not within the box. This is strictly a performance thing. They only exist as helpers if you don't/can't set those up.
Below are instructions for installing Laravel in no time. Alternatively, you can download Laravel manually and just drag and drop. There's also a way to do this with Composer.
cd my/favorite/folder/for/storing/projects git clone https://github.com/scotch-io/scotch-box my-new-laravel-project cd my-new-laravel-project vagrant up vagrant ssh cd /var/www laravel new project # Patience, let it download and do its thing... rm -rf README.md .gitignore public/ # Removing conflicting files mv project/* project/.[^.]* . # Put Laravel files in right spot rm -rf project # All done
Now, you should add
.vagrant to the .gitignore. If you visit: http://192.168.33.10/ you should see L5 at this point!
Alternatively, Laravel's Homestead is probably the best Vagrant setup for Laravel projects although Scotch Box will work perfectly fine.
Setting up WordPress is even easier. Here's how:
cd my/favorite/folder/for/storing/projects git clone https://github.com/scotch-io/scotch-box my-new-wordpress-project cd my-new-wordpress-project vagrant up vagrant ssh cd /var/www/public rm index.php git clone https://github.com/WordPress/WordPress --depth=1 .
Now, just copy
wp-config.php. After this, configure your database settings with MySQL settings in the docs. You're all set!
Since this works out of the box, all you need to do is:
vagrant ssh wp --info
Mailcatcher is added to the box so we can test emails. This is already setup and configured, you just need to turn it on. Here's how:
vagrant ssh mailcatcher --http-ip=0.0.0.0
Now, navigate to 192.168.33.10:1080 in your browser to see it in action.
If you want Mailcatcher to start on
vagrant up, just add this to your
config.vm.provision "shell", inline: <<-SHELL mailcatcher --http-ip=0.0.0.0 SHELL
Use Older Versions of Scotch Box
If you hate this, we support older versions. You can set a version of Scotch Box in your Vagrantfile like so:
config.vm.box_version < 2.5
Update Policy and the Future of Scotch Box
We'll continue to support and update the box. It's important to note though that Vagrant is shifting their focus to the Otto Project. The Otto Project does basically what Scotch Box already does for you and gives you a dead-simple LAMP stack. It also has deployments. The problem is this is super-duper alpha. So as it progresses we'll update Scotch Box with details on when you too should make the switch.