UniLab is a students’ centred project. The main objective is to help students in Bachelor or Master levels (or just graduated students) to be prepared to enter the labour market during their studies or as soon as possible after graduation. In order to enable this, the project has develop a Students’ Portal model that focuses on the needs of students.
The UniLab Students’ Portal model is available in English. You can see a sample portal and you can also download the code to develop your own portal from this page.
UniLab is composed of 2 services, a backend written in Python using the Django-Rest-Framework, and a Single-Page-Application frontend written in JavaScript using React.
The backend needs to be run by the server on port 8000. The frontend runs on port 8080, and is composed of just an nginx server which returns the whole application as a single html file (google Single-Page-Applications for more information)
There is configuration to be made for the backend on backend/UniLab/production_settings.py like the URL that you are deploying the backend on. also on backend/Unilab/general_settings.py there is there configuration of the Postgres user and password and secret key.
sudo apt install python3-venv python3-dev libpq-dev postgresql postgresql-contrib nginx curl
sudo -u postgres psql
CREATE DATABASE unilab_db;
CREATE USER db_admin WITH PASSWORD 'UniLab#93580';
ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE myprojectuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
\q
mkdir ~/VENVs
cd ~/VENVs
python3 -m venv unilab_v2
source unilab_v2/bin/activate
You should now see your terminal start each line with (unilab_v2). This means the VENV is activated.
cd ~/Unilab_v2/backend #or wherever your cloned repository is
pip install django gunicorn psycopg2-binary
pip install -r ./requirements.txt
./manage.py makemigrations api
./manage.py migrate
sudo ufw allow 8000
gunicorn --bind 0.0.0.0:8000 UniLab.wsgi
deactivate
sudo nano /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo nano /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=<username>
Group=www-data
WorkingDirectory=/home/<username>/UniLab_v2
ExecStart=/home/<username>/VENVs/unilab_v2/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
UniLab_v2.wsgi:application
[Install]
WantedBy=multi-user.target
save and close
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
sudo systemctl status gunicorn.socket
you should receive an output like this:
Output
● gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: active (listening) since Mon 2022-04-18 17:53:25 UTC; 5s ago
Triggers: ● gunicorn.service
Listen: /run/gunicorn.sock (Stream)
CGroup: /system.slice/gunicorn.socket
Apr 18 17:53:25 django systemd[1]: Listening on gunicorn socket.
sudo nano /etc/nginx/sites-available/unilab_v2
server {
listen 8000;
server_name <server_domain_or_IP>;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/<username>/UniLab_v2;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
save and close
sudo ln -s /etc/nginx/sites-available/unilab_v2 /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
sudo ufw allow 'Nginx Full'
sudo systemctl restart gunicorn
sudo systemctl daemon-reload
sudo systemctl restart gunicorn.socket gunicorn.service
cd ~/UniLab_v2/frontent
npm run build
cat /etc/nginx/sites-available/unilab_v2
server {
listen 80;
listen [::]:80;
root /var/www/<your_domain>/html;
index index.html index.htm index.nginx-debian.html;
server_name <your_domain> www.<your_domain>;
location / {
try_files $uri $uri/ =404;
}
}
UniLab is composed of 2 services, a backend written in Python using the Django-Rest-Framework, and a Single-Page-Application frontend written in JavaScript using React.
The backend needs to be run by the server on port 8000. The frontend runs on port 8080, and is composed of just an nginx server which returns the whole application as a single html file (google Single-Page-Applications for more information)
There is configuration to be made for the backend on backend/UniLab/production_settings.py like the URL that you are deploying the backend on. also on backend/Unilab/general_settings.py there is there configuration of the Postgres user and password and secret key.
sudo apt update
sudo apt install python3-venv python3-dev libpq-dev postgresql postgresql-contrib nginx curl
sudo -u postgres psql
CREATE DATABASE unilab_db;
CREATE USER db_admin WITH PASSWORD 'UniLab#93580';
ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE myprojectuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
\q
mkdir ~/VENVs
cd ~/VENVs
python3 -m venv unilab_v2
source unilab_v2/bin/activate
You should now see your terminal start each line with (unilab_v2). This means the VENV is activated.
cd ~/Unilab_v2/backend #or wherever your cloned repository is
pip install django gunicorn psycopg2-binary
pip install -r ./requirements.txt
./manage.py makemigrations api
./manage.py migrate
sudo ufw allow 8000
gunicorn --bind 0.0.0.0:8000 UniLab.wsgi
deactivate
sudo nano /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo nano /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=<username>
Group=www-data
WorkingDirectory=/home/<username>/UniLab_v2
ExecStart=/home/<username>/VENVs/unilab_v2/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
UniLab_v2.wsgi:application
[Install]
WantedBy=multi-user.target
save and close
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
sudo systemctl status gunicorn.socket
you should receive an output like this:
Output
● gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: active (listening) since Mon 2022-04-18 17:53:25 UTC; 5s ago
Triggers: ● gunicorn.service
Listen: /run/gunicorn.sock (Stream)
CGroup: /system.slice/gunicorn.socket
Apr 18 17:53:25 django systemd[1]: Listening on gunicorn socket.
sudo nano /etc/nginx/sites-available/unilab_v2
server {
listen 8000;
server_name <server_domain_or_IP>;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/<username>/UniLab_v2;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
save and close
sudo ln -s /etc/nginx/sites-available/unilab_v2 /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
sudo ufw allow 'Nginx Full'
sudo systemctl restart gunicorn
sudo systemctl daemon-reload
sudo systemctl restart gunicorn.socket gunicorn.service
cd ~/UniLab_v2/frontent
npm run build
cat /etc/nginx/sites-available/unilab_v2
server {
listen 80;
listen [::]:80;
root /var/www/<your_domain>/html;
index index.html index.htm index.nginx-debian.html;
server_name <your_domain> www.<your_domain>;
location / {
try_files $uri $uri/ =404;
}
}
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |