Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/suhailvs/stackschools


https://github.com/suhailvs/stackschools

Last synced: 9 days ago
JSON representation

Awesome Lists containing this project

README

        

# Stack Schools

[![Python Version](https://img.shields.io/badge/python-3.8-brightgreen.svg)](https://python.org)
[![Django Version](https://img.shields.io/badge/django-3.1-brightgreen.svg)](https://djangoproject.com)
[![CircleCI](https://circleci.com/gh/suhailvs/django-schools.svg?style=svg)](https://circleci.com/gh/suhailvs/django-schools)

## Running the Project Locally

First, clone the repository to your local machine:

```bash
git clone https://github.com/suhailvs/stackschools
```

Create Virtual Env and Install the requirements:

```bash
cd stackschools
python3 -m venv env
source ./env/bin/activate
pip install -r requirements.txt
```

## Deployment

Install Apache:

$ apt-get update
$ apt-get install python3-pip apache2 libapache2-mod-wsgi-py3

+ Change dir: `$ cd /var/www/`
+ Clone the repo: `$ git clone https://github.com/suhailvs/stackschools`
+ Change dir: `$ cd stackschools`

Create virtual and install django:

$ python3 -m venv env
$ source ./env/bin/activate
$ apt install libpq-dev
$ apt install gdal-bin
$ apt install postgis
$ pip install -r requirements.txt
$ mkdir media
$ chown www-data:www-data media
$ cp .env.sample .env # update it
$ ./manage.py collectstatic

Edit apache config :

Django conf:

$ vim /etc/apache2/sites-available/stackschools.conf


ServerName stackschools.com
ServerAlias www.stackschools.com

AliasMatch ^/sitemap-(.*) /var/www/stackschools/sitemaps/sitemap-$1
Alias /robots.txt /var/www/stackschools/staticfiles/robots.txt
Alias /ads.txt /var/www/stackschools/ads.txt
Alias /favicon.ico /var/www/stackschools/staticfiles/favicon.ico
Alias /media/ /var/www/stackschools/media/
Alias /static/ /var/www/stackschools/staticfiles/


Require all granted


Require all granted


WSGIDaemonProcess stackschoolapp python-home=/var/www/stackschools/env python-path=/var/www/stackschools/
WSGIProcessGroup stackschoolapp
WSGIScriptAlias / /var/www/stackschools/mysite/wsgi.py
# ErrorLog /var/www/stackschools/media/error.log
# CustomLog /var/www/stackschools/media/access.log combined

**lets encrypt for HTTPS**

I had to comment the `WSGIDaemonProcess` line out before running letsencrypt.

$ vim /etc/apache2/sites-available/stackschools.conf

...
# WSGIDaemonProcess stackschoolapp python-home=/var/www/stackschools/env python-path=/var/www/stackschools/

install certbot and run it.

apt-get install python3-certbot-apache
a2ensite stackschools.conf
service apache2 restart
certbot --apache -d stackschools.com -d www.stackschools.com

Then uncommented `WSGIDaemonProcess` in `stackshools.conf` and `stackschools-le-ssl.conf` and in `stackschools-le-ssl.conf` change `stackschoolapp` to `stackschoolappssl`.

restart apache:

$ a2ensite stackschools.conf
$ service apache2 reload

## Create the database:

#### You might need to install postgresql:

```bash
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo -u postgres psql

ALTER USER postgres WITH PASSWORD 'root';
create database stackschools;
```

**migrate:**

./manage.py migrate

**Load School Database**

git clone https://github.com/sta-k/stackschools_datas
cd stackschools_datas
tar xvf data_sql.tar.xz
psql -U postgres -d stackschools < keralaschools.sql
psql -U postgres -d stackschools < schools.sql
psql -U postgres -d stackschools < colleges.sql
rm keralaschools.sql schools.sql colleges.sql

**Dump database**

sudo su postgres
pg_dump --data-only -d stackschools -t > /tmp/file.sql

**Upload sitemaps**

./manage.py generate_sitemap

zip `sitemaps` folder inside `media`, then commit and push

https://github.com/just-work/django-sitemap-generate