| Version | Date | Notes | By |
|---|---|---|---|
| 0.1 | 2021-07-13 | Initial release | acl |
As example we are using sgi.wemake.pt and sgi-back.wemake.pt as the domains. This should be changed to the real subdomains.
Clone the core project using: git clone <https-link> <backend-folder>
Go to the backend folder and create the .env file using: cp .env.example .env
Check how many licenses the client has. Also check or ask for the client number in order to update the root and wemake users' passwords
Set random app key on .env file (just so a package from composer can be installed, you cannot use yet the php artisan key:generate command). You can use this app_key for now: base64:rmoQ7TT61ll/UvSARXWOmPPniautyOaiypjoKoMfmEI=
Install composer packages using: composer install --no-dev
Install the modules needed using: composer require <modules>
Set the proper permissions using: sudo chown -R www-data storage/ bootstrap/cache/ and sudo chmod -R 775 storage/ bootstrap/cache/
Generate an application key using: php artisan key:generate
Generate the JWT secret php artisan jwt:secret
Create the database, database user and assign proper privileges.
DO NOT FORGET to write down the user, database name and password
sudo mysql
CREATE DATABASE <database_name> CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER '<user>'@'localhost' IDENTIFIED BY '<password>'; (you can use bitwarden or the following command to generate a password: `openssl rand -base64 32`)
GRANT ALL PRIVILEGES ON <database_name>.* TO '<user>'@'localhost';
View this document to check which REDIS_DB_NUM and REDIS_DB_CACHE to use, as well as the echo server port and add those in https://docs.google.com/spreadsheets/d/1NL24JtrzUMBAhj2nftBQGdZmb8kQO5nc0_henXVuZK4/edit?usp=sharing
Update the .env file (no need to say this though)
Run migrations and seed translations using: php artisan migrate && php artisan reseed
Update root and wemake users' passwords using: php artisan tinker and on tinker run User::whereKey([1, 2])->update(['password' => Hash::make(<password>)])
Test apache configuration, will throw errors if there's something wrong, using: sudo apachectl configtest
Go to /etc/apache2/sites-available/ and create a new apache configuration file with the following name sgi-back.wemake.pt.conf
HTTP
<Directory /var/www/html/sgi-back.wemake.pt/public>
AllowOverride All
Require all granted
</Directory>
<VirtualHost sgi-back.wemake.pt:80>
ServerName sgi-back.wemake.pt
DocumentRoot /var/www/html/sgi-back.wemake.pt/public
ErrorLog /var/log/apache2/sgi-back.wemake.pt.error.log
CustomLog /var/log/apache2/sgi-back.wemake.pt.access.log combined
</VirtualHost>
HTTPS
<Directory /var/www/html/sgi-back.wemake.pt/public>
AllowOverride All
Require all granted
</Directory>
<VirtualHost sgi-back.wemake.pt:443>
ServerName sgi-back.wemake.pt
DocumentRoot /var/www/html/sgi-back.wemake.pt/public
SSLEngine on
SSLCertificateFile <path_to_cert_file>
SSLCertificateKeyFile <path_to_key_file>
ErrorLog /var/log/apache2/sgi-back.wemake.pt.error.log
CustomLog /var/log/apache2/sgi-back.wemake.pt.access.log combined
</VirtualHost>
Enable the new configuration using: sudo a2ensite sgi-back.wemake.pt.conf
Reload apache using: sudo systemctl reload apache2
Test that the backend is online: http://sgi-back.wemake.pt/ you should get a 404 page error, which is normal because there's no route for root
Create the laravel echo server config file using: cp laravel-echo-server.example.json laravel-echo-server.json
Update the laravel echo server config file
HTTP
{
"appKey": "47r1i66li4cn9anb4pocpb9h6eb5fc7d35f5lhs363gho1kmqcqf2tred6p2",
"authHost": "https://sgi-back.wemake.pt",
"authEndpoint": "/broadcasting/auth",
"database": "redis",
"databaseConfig": {
"redis": {
"port": "6379",
"host": "127.0.0.1",
"options": {
"db": <REDIS_DB_NUM>
}
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "sgi-back.wemake.pt",
"port": <laravel-echo-server-port>,
"referrers": [
{
"host": "*",
"apiKey": "nrhmk8ic64lgnqbs6t794gpj6per33ho5q34j2mrgia61j8hf238rf0c014b"
}
],
"socketio": {
"wsEngine": "uws"
},
"protocol": "http",
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": false
}
HTTPS
{
"appKey": "47r1i66li4cn9anb4pocpb9h6eb5fc7d35f5lhs363gho1kmqcqf2tred6p2",
"authHost": "https://sgi-back.wemake.pt",
"authEndpoint": "/broadcasting/auth",
"database": "redis",
"databaseConfig": {
"redis": {
"port": "6379",
"host": "127.0.0.1",
"options": {
"db": <REDIS_DB_NUM>
}
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "sgi-back.wemake.pt",
"port": <laravel-echo-server-port>,
"referrers": [
{
"host": "*",
"apiKey": "nrhmk8ic64lgnqbs6t794gpj6per33ho5q34j2mrgia61j8hf238rf0c014b"
}
],
"socketio": {
"wsEngine": "uws"
},
"protocol": "https",
"sslCertPath": "<path_to_cert_file>",
"sslKeyPath": "<path_to_key_file>",
"verifyAuthPath": true,
"verifyAuthServer": false
}
Run laravel-echo-server start on the backend folder and check if it works. If it is working, stop it by doing CTRL+C
Use supervidord to configure the service, create a new file /etc/supervisor/conf.d/sgi.wemake.pt.conf and use the following configuration (change as needed)
[program:<client name>-laravel-echo-server]
directory=/var/www/html/sgi-back.wemake.pt
command=/usr/bin/laravel-echo-server start
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/var/www/html/sgi-back.wemake.pt/storage/logs/laravel-echo-server.log
Use sudo supervisorctl reread && sudo supervisorctl update in order for the new configuration to be available
sudo supervisorctl start <client name>-laravel-echo-server
Edit the same file (/etc/supervisor/conf.d/sgi.wemake.pt.conf) and add this for the laravel-queue-work
[program:<client name>-laravel-queue-work]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/sgi-back.wemake.pt/artisan queue:work --sleep=3
autostart=true
autorestart=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/html/sgi-back.wemake.pt/storage/logs/laravel-queue-listen.log
Use sudo supervisorctl reread && sudo supervisorctl update in order for the new configuration to be available (same as in step 21)
sudo supervisorctl start <client name>-laravel-queue-work:
Use gulp export on your local machine
Copy the zipped 'export' folder CONTENTS (zip all the files within export folder, not the folder itself) via ssh and put it on the home directory (/home/devel)
Go to /var/www/html and create the frontend folder using: mkdir sgi.wemake.pt
Go to the frontend folder using cd sgi.wemake.pt and then unzip the frontend there using unzip ~/frontend.zip -d .
Update env.js (you can take a look at another frontend folder env.js in case you're not sure about some settings)
Go to /etc/apache2/sites-available/ and create a new apache configuration file with the following name sgi.wemake.pt.conf
HTTP
<Directory /var/www/html/sgi.wemake.pt>
AllowOverride All
Require all granted
</Directory>
<VirtualHost sgi.wemake.pt:80>
ServerName sgi.wemake.pt
DocumentRoot /var/www/html/sgi.wemake.pt
ErrorLog /var/log/apache2/sgi.wemake.pt.error.log
CustomLog /var/log/apache2/sgi.wemake.pt.access.log combined
</VirtualHost>
HTTPS
<Directory /var/www/html/sgi.wemake.pt>
AllowOverride All
Require all granted
</Directory>
<VirtualHost sgi.wemake.pt:443>
ServerName sgi.wemake.pt
DocumentRoot /var/www/html/sgi.wemake.pt
SSLEngine on
SSLCertificateFile <path_to_cert_file>
SSLCertificateKeyFile <path_to_key_file>
ErrorLog /var/log/apache2/sgi.wemake.pt.error.log
CustomLog /var/log/apache2/sgi.wemake.pt.access.log combined
</VirtualHost>
Enable the new configuration using sudo a2ensite sgi.wemake.pt.conf
Run sudo systemctl reload apache2
Test it on sgi.wemake.pt
DO NOT FORGET to disable module dependencies
Try to export a PDF and Excel to check if all permissions are ok
DO NOT FORGET to register the installation on https://docs.google.com/spreadsheets/d/1BqVOwCL8RSKFSLd4W3EJRQOiSbKoXo8mph6qs3rWsmE/edit?usp=sharing