Skip to content

Installation

Eduard Aymerich edited this page Oct 13, 2020 · 5 revisions

1. Install dependencies

1.1) Install Composer 1.8

1.2) Install PHP 7.3.5

1.3) Install Laravel 5.8

2. Setup the project

2.1) Clone this repository

> git clone git@github.com:eduayme/RescueApp.git

2.2) Create new file .env inside the project folder with the same content as .env.example

> cp .env.example .env

2.3) Open terminal inside the project folder and run

> composer update --no-scripts

3. Setup the database

Option a) MySQL

3.a.1) Install MySQL 5.7

3.a.2) Create the database aplicatiu_bombers in mysql

mysql> CREATE DATABASE aplicatiu_bombers;

3.a.3) Change mysql credentials in .env

DB_CONNECTION = mysql
DB_HOST       = 127.0.0.1
DB_PORT       = 3306
DB_DATABASE   = aplicatiu_bombers
DB_USERNAME   = mysql_username
DB_PASSWORD   = mysql_password

Option b) PostgreSQL

3.b.1) Install PostgreSQL 12.0

3.b.2) Create the database aplicatiu_bombers in postgresql

postgresql> CREATE DATABASE aplicatiu_bombers;

3.b.3) Change postgresql credentials in .env

DB_CONNECTION = pgsql
DB_HOST       = 127.0.0.1
DB_PORT       = 5432
DB_DATABASE   = aplicatiu_bombers
DB_USERNAME   = postgresql_username
DB_PASSWORD   = postgresql_password

4. Setup EMAIL configuration

Option a) Gmail via SMTP

4.a.1) Create a gmail account

4.a.2) Go to the account security settings

4.a.3) Active the Allow less secure app option

4.a.4) Change email credentials in .env

MAIL_DRIVER      = smtp
MAIL_HOST        = smtp.gmail.com
MAIL_PORT        = 587
MAIL_USERNAME    = gmail_username
MAIL_PASSWORD    = gmail_password
MAIL_ENCRYPTION  = tls

5. Run the app

5.1) Open a terminal inside the project folder and migrate the database

> php artisan migrate

5.2) Run the application

> php artisan serve

5.3) Open a browser and go to the url 127.0.0.1:8000 or localhost:8000

5.4) RescueApp is running! :)

6. Configuration for the server

Installation example on subdomain RescueApp.mysite.com

Option a) Apache2

6.a.1) Download Apache2

6.a.2) Configure the DNS "A" records for your subdomain as required by your provider

6.a.3) Configure /etc/apache2/sites-enabled/RescueApp.conf adapting the code to your needs: ServeName, DocumentRoot, ssl parameters(we used Letsencrypt), etc.. Example:

<VirtualHost *:80>
        ServerName RescueApp.mysite.com 
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/Rescue-app/public
        Redirect / https://RescueApp.mysite.com 
        <Directory /var/www/html/Rescue-app>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

RewriteEngine on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/Rescue-app/public

        <Directory /var/www/html/Rescue-app>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>
        ServerName RescueApp.mysite.com
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/mysite.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mysite.com/privkey.pem
</VirtualHost>
</IfModule>