2020-12-04 14:55:52 +01:00
#### This Vagrant setup is still a "Work in Progress", though it can be used as is.
2020-01-05 11:03:44 +01:00
2019-01-07 18:31:40 +01:00
# Disroot Howto Development Environment using Vagrant
2020-12-04 14:55:52 +01:00
## Requirements
* **Vagrant 2.2.6**
2020-12-04 15:04:47 +01:00
Commands for Vagrant installation
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
**On Debian based operating systems**
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
wget https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.deb
```
```
sudo dpkg -i vagrant_2.2.6_x86_64.deb
```
```
sudo apt install -f
```
2019-01-07 18:31:40 +01:00
2020-12-04 15:04:47 +01:00
**On Arch based operating systems**
```
sudo pacman -S vagrant
```
2020-12-04 14:55:52 +01:00
* **VirtuaBox**
2020-12-04 15:04:47 +01:00
Commands for VirtuaBox installation
**On Debian Jessie**
```
sudo apt install virtualbox-6.0
```
**On Debian Buster**
```
sudo echo 'deb http://download.virtualbox.org/virtualbox/debian buster contrib' > /etc/apt/sources.list.d/virtualbox.list
```
```
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
```
```
sudo apt-get update ; sudo apt-get install virtualbox-6.0
```
**On Arch based operating systems**
```
sudo pacman -S virtualbox
```
2020-12-04 14:55:52 +01:00
* **Vagrant plugins vagrant-vbguest**
2020-12-04 15:04:47 +01:00
Commands for Vagrant plugins installation
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
vagrant plugin install vagrant-vbguest
```
2019-01-07 18:31:40 +01:00
2020-12-04 15:11:57 +01:00
* **Git**
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
Commands for git installation
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
**On Debian based operating systems**
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
sudo apt install git
```
2019-01-07 18:31:40 +01:00
2020-12-04 15:04:47 +01:00
**On Arch based operating systems**
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
sudo pacman -S git
```
2020-12-04 14:55:52 +01:00
## Installing the Vagrant virtual machine
2020-12-04 15:11:57 +01:00
1. Create the Disroot folder in which the repositories will be cloned, and enter it
2019-01-07 18:31:40 +01:00
2020-12-04 15:04:47 +01:00
```
2020-12-04 15:11:57 +01:00
mkdir ~/Disroot ; cd ~/Disroot
2020-12-04 15:04:47 +01:00
```
2020-12-04 07:40:41 +01:00
2020-12-04 15:11:57 +01:00
2. Clone the Howto repository inside the Disroot folder
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
git clone https://git.disroot.org/Disroot/Howto.git
```
2020-12-04 07:40:41 +01:00
2020-12-04 15:11:57 +01:00
3. Clone the grav-plugin-language-selector repository inside this same Disroot folder
2020-12-04 15:04:47 +01:00
```
2020-12-04 15:11:57 +01:00
git clone https://git.disroot.org/Disroot/grav-plugin-language-selector.git
2020-12-04 15:04:47 +01:00
```
2020-12-04 07:40:41 +01:00
4. Add the local domain name for the hub to your host machine's `/etc/hosts` file.
2019-01-07 18:31:40 +01:00
2020-12-04 15:04:47 +01:00
```
echo "192.168.33.11 howto.disroot.lan" >> /etc/hosts
```
2020-12-04 07:40:41 +01:00
2020-12-04 14:55:52 +01:00
5. Go to the Vagrant folder inside the cloned repository...
2020-12-04 15:04:47 +01:00
```
cd ~/Disroot/howto/vagrant
```
2020-12-04 14:55:52 +01:00
... and launch Vagrant to build the virtual machine (VM). This will take several minutes.
2019-01-07 18:31:40 +01:00
2020-12-04 15:04:47 +01:00
```
vagrant up howto_disroot_lan
```
2020-12-04 14:55:52 +01:00
2020-12-04 15:11:57 +01:00
**Congratulations!** You should now have a fully functioning Nginx + GRAV server running locally in a VirtualBox-hosted VM managed by Vagrant.
2020-12-04 14:55:52 +01:00
Next time you want to run Vagrant simply use the commands
```
2020-12-04 15:04:47 +01:00
cd ~/Disroot/howto/vagrant
vagrant up howto_disroot_lan
vagrant provision
2020-12-04 14:55:52 +01:00
```
2019-01-07 18:31:40 +01:00
### Enable SSH access
2020-12-04 14:55:52 +01:00
To make your development workflow more efficient, you may wish to use an SSH connection to quickly synchronize the files you are developing in your local (host machine) development environment.
2019-01-07 18:31:40 +01:00
1. On your host machine, copy your public key.
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
user@host:~$ cat ~/.ssh/id_rsa.public
ssh-rsa eLX1UQbJHUCHf2V3K7YlMP0YmIT+50rlEsWre1eobApKb0Ac/WbvssX/Gh/ user@host
```
2020-12-04 14:55:52 +01:00
2020-01-05 11:03:44 +01:00
2. Use `vagrant ssh howto_disroot_lan` to log in to the virtual machine.
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
user@host:~$ cd ~/Disroot/howto/vagrant
user@host:hubzilla-vagrant$ vagrant ssh howto_disroot_lan
```
2020-12-04 14:55:52 +01:00
2020-01-05 11:03:44 +01:00
3. Switch to root and add your host user public key.
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
vagrant@stretch:~$ sudo -i
root@jessie:~# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b4:e3:00:40:4f:c5:af:27:05:09:d4:70:29:ac:f8:51 root@jessie
The key's randomart image is:
+---[RSA 2048]----+
| .oo=*oo |
| +E.* |
| . oo. o. |
|. o . .o. |
| . . .oS |
| . oo.. |
| o. |
| |
| |
+-----------------+
root@stretch:~# echo "ssh-rsa eLX1UQbJHUCHf2V3K7YlMP0YmIT+50rlEsWre1eobApKb0Ac/WbvssX/Gh/ user@host" >> ~/.ssh/authorized_keys
```
2020-12-04 14:55:52 +01:00
2020-01-05 11:03:44 +01:00
4. From your host machine, you may now SSH into the virtual machine using
2020-12-04 14:55:52 +01:00
2020-12-04 15:04:47 +01:00
```
ssh root@howto.disroot.lan
```