The configuration files used to create the nijens/apache-php-mysql Vagrant base box.
Execute the following commands inside your project to initialize the Vagrant Virtualbox image.
vagrant init nijens/apache-php-mysql
vagrant up
To configure Apache and make it available for you to access you will require to add the following:
- An Apache configuration file suitable for your project.
- Create a port forward to be able to access Apache from your browser.
The following configuration links to an Apache configuration inside your project and creates a port forward:
Vagrant.configure("2") do |config|
config.vm.box = "nijens/apache-php-mysql"
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
config.vm.provision "shell", inline: "sudo ln -s /vagrant/path/to/apache.conf /etc/apache/sites-enabled/apache.conf"
end
Make sure the document root of your Apache configuration is directed to /vagrant
.
Some projects require, besides a MySQL database, an Elasticsearch database to run. For this case a shell script is provided to easily add it to your box.
The following configuration shows how to add the script to your configuration and install Elasticsearch 2.x:
Vagrant.configure("2") do |config|
# ...
config.vm.provision "shell",
path: "https://raw.githubusercontent.com/nijens/vagrant-apache-php-mysql/master/provision/elasticsearch.sh",
sha1: 5504b8c4a2d0eac994f98ca6b963d8a24228b83e,
args: ["2"]
# ...
end
In the above example version 2.x of Elasticsearch is installed by adding args: ["2"]
, but you can also install version 6.x by changing the version number.
For more information on configuration of your Vagrant box, see the Vagrant documentation.