https://github.com/suhailvs/stackschools
https://github.com/suhailvs/stackschools
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/suhailvs/stackschools
- Owner: suhailvs
- License: mit
- Created: 2022-01-30T05:50:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T12:05:20.000Z (8 months ago)
- Last Synced: 2024-10-29T13:25:41.540Z (8 months ago)
- Language: Python
- Homepage: https://stackschools.com
- Size: 1.92 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stack Schools
[](https://python.org)
[](https://djangoproject.com)
[](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 collectstaticEdit apache config :
Django conf:
$ vim /etc/apache2/sites-available/stackschools.conf
ServerName stackschools.com
ServerAlias www.stackschools.comAliasMatch ^/sitemap-(.*) /var/www/stackschools/sitemaps/sitemap-$1
Alias /sitemap.xml /var/www/stackschools/sitemaps/sitemap.xml
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.comThen 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 psqlALTER USER postgres WITH PASSWORD 'root';
create database stackschools;
```**migrate:**
./manage.py migrate
**Load School Database**
see https://github.com/sta-k/stackschools_datas
#### Create and upload sitemaps
**update django core sitemap**
since urls in `sitemap.xml` will look like `sitemap-college.xml?p=3` so need to change it to `sitemap-college3.xml`, to fix edit django file `env/lib/python3.12/site-packages/django/contrib/sitemaps/views.py` line 85 with::
SitemapIndexItem(absolute_url.replace('.xml',f'{page}.xml'), site_lastmod)
**update mysite/urls.py**
uncomment sitempas in `mysite/urls.py`::
path('sitemap.xml', sitemaps_views.index, {'sitemaps': my_sitemaps},
name='django.contrib.sitemaps.views.index'),
path('sitemap-.xml', sitemaps_views.sitemap, {'sitemaps': my_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
**generate sitemap**./manage.py generate_sitemap
zip `sitemaps` folder inside `media`, then copy it to `github.com/sta-k/stackschools_datas`. then commit and push
**upload sitemaps to server**
pull the changes in stackschools_datas and move folder `sitemaps` to `/var/www/stackschools/`.