forked from Disroot/Howto
Vagrant
This commit is contained in:
parent
b10ff4590f
commit
af68eb5fe6
5 changed files with 221 additions and 0 deletions
2
vagrant/.gitignore
vendored
Normal file
2
vagrant/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# vagrant folder
|
||||
.vagrant/
|
104
vagrant/README.md
Normal file
104
vagrant/README.md
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Disroot Howto Development Environment using Vagrant
|
||||
|
||||
## requrements
|
||||
1. vagrant 2.2.1
|
||||
for install on Debian run commands:
|
||||
```
|
||||
wget https://releases.hashicorp.com/vagrant/2.2.1/vagrant_2.2.1_x86_64.deb
|
||||
```
|
||||
```
|
||||
sudo dpkg -i vagrant_2.2.1_x86_64.deb
|
||||
```
|
||||
```
|
||||
sudo apt install -f
|
||||
```
|
||||
|
||||
2. virtuabox
|
||||
for install on Debian run command:
|
||||
```
|
||||
sudo apt install virtualbox-6.0
|
||||
```
|
||||
|
||||
3. vagrant plugins vagrant-vbguest:
|
||||
for install on Debian run commands:
|
||||
```
|
||||
vagrant plugin install vagrant-vbguest
|
||||
```
|
||||
```
|
||||
vagrant vbguest
|
||||
```
|
||||
|
||||
4. git
|
||||
```
|
||||
sudo apt install git
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone howto repo to howto project folder
|
||||
```
|
||||
git clone https://git.fosscommunity.in/disroot/howto.git ~/howto
|
||||
```
|
||||
2. Add the local domain name for the hub to your host machine's `/etc/hosts` file.
|
||||
|
||||
```
|
||||
echo "192.168.33.11 howto.disroot.lan" >> /etc/hosts
|
||||
```
|
||||
3. Launch Vagrant to build the virtual machine (VM). This will take several minutes.
|
||||
```
|
||||
cd ~/howto/vagrant
|
||||
vagrant up howto_disroot_lan
|
||||
```
|
||||
|
||||
Congratulations, you should now have a fully functioning apache+GRAV server running locally in a Virtualbox-hosted VM managed by Vagrant. Next time you want to run vagrant simply run command
|
||||
```
|
||||
cd ~/howto/vagrant
|
||||
vagrant up howto_disroot_lan
|
||||
```
|
||||
|
||||
### Enable SSH access
|
||||
|
||||
To make your development workflow more efficient, you may wish to use an SSH connection to rapidly synchronize the files you are developing in your local (host machine) development environment.
|
||||
|
||||
1. On your host machine, copy your public key.
|
||||
```
|
||||
user@host:~$ cat ~/.ssh/id_rsa.public
|
||||
ssh-rsa eLX1UQbJHUCHf2V3K7YlMP0YmIT+50rlEsWre1eobApKb0Ac/WbvssX/Gh/ user@host
|
||||
```
|
||||
1. Use `vagrant ssh howto_disroot_lan` to log in to the virtual machine.
|
||||
```
|
||||
user@host:~$ cd ~/howto/vagrant
|
||||
user@host:hubzilla-vagrant$ vagrant ssh howto_disroot_lan
|
||||
```
|
||||
1. Switch to root and add your host user public key.
|
||||
```
|
||||
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
|
||||
```
|
||||
1. From your host machine, you may now SSH into the virtual machine using
|
||||
```
|
||||
ssh root@howto.disroot.lan
|
||||
```
|
||||
|
27
vagrant/Vagrantfile
vendored
Normal file
27
vagrant/Vagrantfile
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.define "howto_disroot_lan" do |howto_disroot_lan|
|
||||
howto_disroot_lan.vm.box="debian/stretch64"
|
||||
howto_disroot_lan.vm.hostname = 'howto.disroot.lan'
|
||||
howto_disroot_lan.vm.box_url = "debian/stretch64"
|
||||
|
||||
howto_disroot_lan.vm.synced_folder "provision/", "/vagrant/provision/"
|
||||
# howto_disroot_lan.vm.synced_folder "../pages/", "/var/www/howto.disroot.lan/user/pages", owner: "www-data", group: "www-data"
|
||||
|
||||
howto_disroot_lan.vm.network "forwarded_port", guest: 80, host: 8888, host_ip: "192.168.33.11"
|
||||
howto_disroot_lan.vm.network "forwarded_port", guest: 443, host: 4443, host_ip: "192.168.33.11"
|
||||
howto_disroot_lan.vm.network "private_network", ip: "192.168.33.11"
|
||||
|
||||
howto_disroot_lan.vm.provision :shell, path: "bootstrap.sh"
|
||||
|
||||
howto_disroot_lan.vm.synced_folder "../pages/", "/var/www/pages", owner: "www-data", group: "www-data"
|
||||
|
||||
|
||||
end
|
||||
end
|
68
vagrant/bootstrap.sh
Executable file
68
vagrant/bootstrap.sh
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Custom configuration
|
||||
H2DIR="howto.disroot.lan"
|
||||
WEBROOT="/var/www/$H2DIR"
|
||||
WWWUSER="www-data"
|
||||
|
||||
# Provisioning actions
|
||||
|
||||
# Add dotdeb repository to sources.list for PHP7.0
|
||||
# echo "deb http://packages.dotdeb.org jessie all" | sudo tee -a /etc/apt/sources.list.d/dotdeb.list
|
||||
# echo "deb-src http://packages.dotdeb.org jessie all" | sudo tee -a /etc/apt/sources.list.d/dotdeb.list
|
||||
# Dotdeb Key for PHP7.0
|
||||
# wget -qO - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -
|
||||
sudo apt-get -y update
|
||||
|
||||
echo "Installing Apache.."
|
||||
sudo apt-get install -y apache2 composer
|
||||
echo "Installing php7.."
|
||||
sudo apt-get install -y php7.0-zip php7.0-cli php7.0-curl php7.0-gd php7.0-mysql php7.0-mbstring php7.0-xml libapache2-mod-php7.0 php7.0-mcrypt php7.0-fpm
|
||||
|
||||
# Enable all the Apache mods
|
||||
sudo a2enmod proxy proxy_fcgi rewrite
|
||||
sudo phpenmod mcrypt zip
|
||||
|
||||
# Create the Apache config files and restart webserver
|
||||
sudo rsync -cr /vagrant/provision/etc/apache2/sites-available/ /etc/apache2/sites-available/
|
||||
sudo sed -i "s/ServerName V_DOMAIN_NAME/ServerName $H2DIR/g" /etc/apache2/sites-available/*.conf
|
||||
sudo sed -i "s/V_DOMAIN_NAME/$H2DIR/g" /etc/apache2/sites-available/*.conf
|
||||
sudo a2ensite "$H2DIR".conf
|
||||
sudo a2enconf php7.0-fpm
|
||||
sudo rm /etc/apache2/sites-enabled/000-default.conf
|
||||
sudo service apache2 restart
|
||||
|
||||
# Install GRAV in webroot
|
||||
composer create-project getgrav/grav $WEBROOT
|
||||
cd $WEBROOT
|
||||
sudo chown -R www-data:www-data $WEBROOT
|
||||
sudo chmod 775 -R bin/
|
||||
sudo -u www-data bin/grav install
|
||||
sudo -u www-data bin/gpm install learn2
|
||||
sudo -u www-data bin/gpm install language-selector
|
||||
sudo -u www-data sed -i 's/quark/learn2/g' $WEBROOT/user/config/system.yaml
|
||||
sudo -u www-data ex -s -c '13i|redirect_default_route: true' -c x $WEBROOT/user/config/system.yaml
|
||||
sudo -u www-data echo "
|
||||
languages:
|
||||
supported:
|
||||
- en
|
||||
- fr
|
||||
- es
|
||||
- pt
|
||||
- it
|
||||
- pl" >> $WEBROOT/user/config/system.yaml
|
||||
sudo -u www-data sed -i '4d' $WEBROOT/user/config/system.yaml
|
||||
sudo -u www-data ex -s -c "4i| alias: '/basics'" -c x $WEBROOT/user/config/system.yaml
|
||||
sudo -u www-data sed -i 's/false/true/g' $WEBROOT/user/plugins/language-selector/language-selector.yaml
|
||||
sudo -u www-data cp $WEBROOT/user/plugins/language-selector/templates/partials/language-selector.html.twig $WEBROOT/user/themes/learn2/templates/partials/
|
||||
sudo -u www-data ex -s -c "9i| {% include 'partials/language-selector.hreflang.html.twig' %}" -c x $WEBROOT/user/themes/learn2/templates/partials/base.html.twig
|
||||
sudo -u www-data sed -i '2d' $WEBROOT/user/themes/learn2/css-compiled/theme.css
|
||||
sudo -u www-data rm $WEBROOT/user/themes/learn2/scss/theme/_fonts.scss
|
||||
sudo -u www-data rm -R $WEBROOT/user/pages
|
||||
|
||||
# Add how2 domain to local /etc/hosts file
|
||||
sudo sed -i "s/127.0.0.1\tlocalhost/127.0.0.1\tlocalhost $H2DIR/" /etc/hosts
|
||||
|
||||
#Add How to pages in GRAV
|
||||
sudo -u www-data ln -s /var/www/pages/ /var/www/howto.disroot.lan/user/
|
||||
exit 0
|
|
@ -0,0 +1,20 @@
|
|||
<VirtualHost *:80>
|
||||
ServerName V_DOMAIN_NAME
|
||||
|
||||
DocumentRoot /var/www/V_DOMAIN_NAME
|
||||
|
||||
<Directory /var/www/V_DOMAIN_NAME/>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
<IfModule mod_php7.c>
|
||||
php_admin_value upload_max_filesize 100M
|
||||
php_admin_value max_file_uploads 50
|
||||
</IfModule>
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
Loading…
Reference in a new issue