Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update vagrant script and doc
  • Loading branch information
asbiin committed Feb 17, 2018
commit 02098c2c0a169d95d55b71a11e45b71b8fd2febc
30 changes: 21 additions & 9 deletions docs/installation/vagrant.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ If you want a quick and easy way to get a Monica development/test environment up

1. Download and install [Vagrant](https://www.vagrantup.com/) for your operating system
2. Create a folder to put the vagrant configuration files
3. Download the `Vagrantfile` and the `provision.sh` script from [this repository](https://github.com/dp87/vagrantfiles/tree/master/Monica)
4. Put both of these files inside the Vagrant folder you have created in step 2
5. Open a terminal and `cd` to this folder
6. Initialize a virtual machine based on Ubuntu 16.04: `vagrant init ubuntu/xenial64`
7. Launch the virtual machine with `vagrant up`
```sh
mkdir ~/monica
cd ~/monica
```
3. Download the `Vagrantfile` and the `provision.sh` script
```sh
curl -sS https://raw.githubusercontent.com/monicahq/monica/master/scripts/vagrant/Vagrantfile -o Vagrantfile
curl -sS https://raw.githubusercontent.com/monicahq/monica/master/scripts/vagrant/provision.sh -o provision.sh
```
4. Initialize a virtual machine based on Ubuntu 16.04:
```sh
vagrant box add ubuntu/xenial64
```
5. Launch the virtual machine with
```sh
vagrant up
```

The virtual machine will be first created and then provisioned using the `provision.sh` script, which will take care of installing Monica for you.

Expand All @@ -19,11 +31,11 @@ Once the installation process is complete (you will see all of the output in you
### Database users

* Root database user
* * Username: `root`
* * Password: `changeme`
- Username: `root`
- Password: `changeme`
* Monica database user
* * Username: `monica`
* * Password: `changeme`
- Username: `monica`
- Password: `changeme`

### Apache configuration

Expand Down
2 changes: 2 additions & 0 deletions scripts/vagrant/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.log
.vagrant/
10 changes: 10 additions & 0 deletions scripts/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"

config.vm.network "forwarded_port", guest: 80, host: 8080

config.vm.provision "shell", path: "provision.sh"
end
79 changes: 79 additions & 0 deletions scripts/vagrant/provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

#
# Author: Daniel Pellarini
# GitHub profile: dp87 - https://github.com/dp87/
# Date: 11/12/2017
#
# Provisioning script to install Monica Personal Relationship Manager on a Ubuntu 16.04 box
#

echo "########################"
echo "Installing prerequisites"
echo "########################"

echo "Installing apache"
apt-get update
apt-get install -y apache2

echo "ServerName vagrant" >> /etc/apache2/apache2.conf # suppress apache warning
systemctl restart apache2

echo "Installing MySQL with default root password"
debconf-set-selections <<< 'mysql-server mysql-server/root_password password changeme'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password changeme'
apt-get install -y mysql-server mysql-client

#echo "Installing PHP"
#apt-get install -y php libapache2-mod-php php-mcrypt php-mysql >/dev/null 2>&1

echo "Installing PHP 7.1"
add-apt-repository -y ppa:ondrej/php
apt-get update >/dev/null
apt-get install -y php7.1 >/dev/null

echo "Installing git"
apt-get install -y git >/dev/null

echo "Installing composer"
apt-get install -y curl php7.1-cli git
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

echo "Installing packages for Monica"
apt-get install -y php7.1-intl php7.1-simplexml php7.1-gd php7.1-mbstring php7.1-curl php7.1-zip php7.1-mysql

echo "Getting database ready"
mysql -uroot -pchangeme -e "CREATE DATABASE monica;
CREATE USER 'monica'@'localhost' IDENTIFIED BY 'changeme';
GRANT ALL ON monica.* TO 'monica'@'localhost';
FLUSH PRIVILEGES;"

echo "Installing Monica"
git clone https://github.com/monicahq/monica.git /var/www/html/monica
cd /var/www/html/monica/
chown -R www-data:www-data /var/www/html/monica
sudo -u www-data composer install --no-interaction --prefer-dist --no-suggest --optimize-autoloader --no-dev --no-progress

echo "Configuring Monica"
sudo -u www-data cp .env.example .env
sudo -u www-data sed -i 's/\(DB_USERNAME\).*/\1=monica/g' .env
sudo -u www-data sed -i 's/\(DB_PASSWORD\).*/\1=changeme/g' .env
sudo -u www-data sed -i 's/\(APP_DISABLE_SIGNUP\).*/\1=false/g' .env
sudo -u www-data php artisan key:generate
sudo -u www-data php artisan setup:production --force [email protected] --password=admin
sudo -u www-data php artisan passport:install

echo "Configuring cron script"
{ crontab -l -u www-data; echo '* * * * * /usr/bin/php /var/www/html/monica/artisan schedule:run'; } | crontab -u www-data -

echo "Configuring apache"
a2enmod rewrite
sed -i 's%\(DocumentRoot\).*%\1 /var/www/html/monica/public%g' /etc/apache2/sites-enabled/000-default.conf
sed -i 's%/var/www/%/var/www/html/monica/public/%g' /etc/apache2/apache2.conf
sed -i '/<Directory \/var\/www\/html\/monica\/public\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf

echo "Restarting apache"
service apache2 restart

echo "Done! You can access Monica by visiting http://localhost:8080 from your host machine"