135 lines
3.2 KiB
Markdown
135 lines
3.2 KiB
Markdown
# Vagrantfile
|
|
|
|

|
|
|
|
Vagrantfile with [Scotch Box](http://box.scotch.io).
|
|
|
|
## Getting Started
|
|
|
|
If you use Vagrant, this [box](https://box.scotch.io) can help you a lot.
|
|
|
|
With this Vagrantfile, you can easily use and implement many *webapps* with a self-certificate signed.
|
|
|
|
### Prerequisites
|
|
|
|
* Virtualbox - https://www.virtualbox.org;
|
|
* Vagrant - https://www.vagrantup.com;
|
|
|
|
### Installing
|
|
|
|
Install Virtualbox and Vagrant.
|
|
|
|
After that, go the main project folder and save this file and run the following command:
|
|
|
|
```
|
|
vagrant up
|
|
```
|
|
|
|
This command will mount all the environment to you.
|
|
|
|
|
|
## Create a self-signed certificate
|
|
|
|
Run the command:
|
|
|
|
```
|
|
vagrant ssh
|
|
```
|
|
|
|
and run the following commands to create a self-signed certificate:
|
|
|
|
```
|
|
sudo a2enmod ssl
|
|
sudo service apache2 restart
|
|
sudo mkdir /etc/apache2/ssl
|
|
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
|
|
sudo a2ensite default-ssl.conf
|
|
```
|
|
|
|
Create or move the file scotchbox.local.conf:
|
|
```
|
|
sudo nano /etc/apache2/sites-available/scotchbox.local.conf
|
|
```
|
|
|
|
```
|
|
<VirtualHost *:443>
|
|
ServerAdmin webmaster@localhost
|
|
ServerName scotchbox.local
|
|
ServerAlias www.scotchbox.local
|
|
DocumentRoot /var/www/public
|
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
|
SSLEngine on
|
|
SSLCertificateFile /etc/apache2/ssl/apache.crt
|
|
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
|
|
<FilesMatch "\.(cgi|shtml|phtml|php)$">
|
|
SSLOptions +StdEnvVars
|
|
</FilesMatch>
|
|
<Directory /usr/lib/cgi-bin>
|
|
SSLOptions +StdEnvVars
|
|
</Directory>
|
|
BrowserMatch "MSIE [2-6]" \
|
|
nokeepalive ssl-unclean-shutdown \
|
|
downgrade-1.0 force-response-1.0
|
|
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
|
|
</VirtualHost>
|
|
|
|
```
|
|
|
|
## Edit Vagrant file for your project
|
|
|
|
Open your Vagrant file and change the line for your project name:
|
|
|
|
```
|
|
VagrantDomain=("app1.dev" "app2.dev" "appN.dev")
|
|
```
|
|
|
|
Edit your hosts, typically sudo nano /etc/hosts - and set:
|
|
|
|
```
|
|
##
|
|
# Host Database
|
|
#
|
|
# localhost is used to configure the loopback interface
|
|
# when the system is booting. Do not change this entry.
|
|
##
|
|
127.0.0.1 localhost
|
|
255.255.255.255 broadcasthost
|
|
::1 localhost
|
|
192.168.33.10 www.app1.dev
|
|
```
|
|
After run the command:
|
|
|
|
```
|
|
vagrant provision
|
|
```
|
|
|
|
|
|
and visit your app in your browser:
|
|
|
|
https://www.app1.dev
|
|
|
|
|
|
## Built With
|
|
|
|
* [virtualbox](https://www.virtualbox.org)
|
|
* [Vagrant](https://www.vagrantup.com)
|
|
* [scotchbox](https://box.scotch.io)
|
|
|
|
## Contributing
|
|
|
|
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on my code of conduct, and the process for submitting pull requests to me.
|
|
|
|
## Versioning
|
|
|
|
I use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://gitlab.andrealmeida.net/public_projects/vagrant/tags).
|
|
|
|
## Authors
|
|
|
|
[](https://andrealmeida.net)
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
|
|
|