3.2 KiB
Personal-site | Production [Tested on server with Hyperbola GNU + Linux-libre]
Python dependencies
- Django
- Pillow
- psycopg2-binary
- pytz
Production Installation
-
Clone Personal-site ()
git clone https://gitlab.com/heckyel-ng/personal-site /path/to/site
-
Run
virtualenv
.cd /path/to/personalsite && virtualenv ./venv/
-
Activate the virtualenv.
source ./env/bin/activate
-
Install dependencies through
pip
.pip install -r requirements_prod.txt
Configuration Postgres
-
Logion as postgres
sudo su - postgres
-
Create base
createdb namebase
-
Create User (place a password for our user)
createuser -P username
-
Inside the database
psql -d namebase
-
Give permissions to the created user
GRANT ALL PRIVILEGES ON DATABASE namebase TO username;
Conecting to Postgres
-
Copy
settings.py.example
tosettings.py
and modify. Make sure to uncomment the appropriate database section (either sqlite or PostgreSQL).Replace sqlite configuartion to postgres, example:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'namebase', 'USER': 'username', 'PASSWORD': 'pass', 'HOST': '127.0.0.1', 'PORT': '5432', } }
-
Migrate changes.
./manage.py migrate
-
Create superUSER
./manage.py createsuperuser
Run with Apache server and wsgi
-
Install WSGI for Apache
sudo pacman -S mod_wsgi
-
To install mod_wsgi, add the following line in
httpd.conf
, example:sudo nano /etc/httpd/conf/httpd.conf
Added line:
LoadModule wsgi_module modules/mod_wsgi.so
-
Create vhosts, for example:
sudo emacs /etc/httpd/conf/extra/httpd-vhosts.conf
and inside write the configuration, example:
<IfModule ssl_module> <VirtualHost *:80> ServerAdmin example@dominio.com ServerName example.com ServerAlias example.com Alias /media /path/to/site/media/ Alias /static /path/to/site/core/static/ <Directory /path/to/site/core/static> Require all granted </Directory> <Directory /path/to/site/media> Require all granted </Directory> <Directory /path/to/site/personalsite> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess personalsite python-home=/path/to/site/venv python-path=/path/to/site WSGIProcessGroup personalsite WSGIScriptAlias / /path/to/site/wsgi.py </VirtualHost> </IfModule>
-
Replace
ALLOWED_HOSTS = []
on setting.py to:
`ALLOWED_HOSTS = ["example.com", "localhost"]`
-
Added on setting.py:
STATIC_ROOT = '/path/to/site/core/static'
-
Create the media/ directory
cd /path/to/personalsite mkdir media/
-
Change Permition to media/ at group http
sudo chown -R http:http media/
-
Restart Apache server
sudo service httpd restart