Best laravel framework open-source packages.

Vagrant lemp

Vagrant LEMP stack
Updated 2 months ago

Vagrant LEMP stack

Tested on Vagrant 2.2.x Tested on VirtualBox 6.0.x Version 2.0

This script will automate the setup of a PHP developement box.

Includes

  • Ubuntu 18.04 (LTS)
  • Nginx 1.14+
  • PHP 7.2+
  • MariaDB 10.1+ (~MySQL 5.7+)
  • Redis 5.0+
  • Memcached
  • Composer

Requirements

Install

You clone this repo in a folder called Vagrant in your home directory.

git clone https://github.com/milhouse1337/vagrant-lemp.git ~/Vagrant
cd ~/Vagrant

You need to remove the .git folder, it will cause conflicts with your own Git repos later.

rm -rf .git

Open the following file:

~/Vagrant/_install/bootstrap.sh

  • Update the MySQL root password.
  • Validate if the rest of the script feels right for you and update as needed.

When everything seems fine you launch it. 🚀

vagrant up

You will have to wait a few seconds (minutes) ☕️ for the script to complete. When everything is done you have a complete LEMP setup to play with. 🤓

Test your setup

Create the following folders and PHP file:

mkdir -p ~/Vagrant/127.0.0.1/public
echo "<?php phpinfo(); ?>" > ~/Vagrant/127.0.0.1/public/index.php

Open the link on your browser:

http://127.0.0.1:8080

You should see a phpinfo() output. 👍

Note: If you want Vagrant to listen on port 80 (or 443 for TLS) you might have to forward the ports with pfctl (the built-in MacOS firewall). More information on this Stack Overflow if you want to know why and how to fix it.

How does it work? 🤔

We use the $host variable from Nginx on the default vhost so the document root is /var/www/{$host}/public for the VM and ~/Vagrant/{$host}/public on your local machine. This emulates the same behavior as VirtualDocumentRoot from Apache but for Nginx.

This means you can use ANY hostname you want (make sure it resolves to 127.0.0.1) then you create the above folder structure (~/Vagrant/{$hostname}/public) to make it work, pretty cool! 😎

Vagrant cheat sheet

vagrant up # Boot. (install if not already provisioned)
vagrant ssh # Login as user "vagrant".
vagrant reload # Reboot.
vagrant halt # Poweroff.
vagrant destroy # Delete.

License

The MIT License (MIT). Please see License File for more information.

Tags redis nginx