From ff670c46798b01403687f42fa314fba2bed03536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Thu, 11 Oct 2018 18:50:26 -0500 Subject: [PATCH] Add documentation in production. It's no longer a myth! \o/ --- HACKING.md | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 - 2 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 HACKING.md diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 0000000..bc150e2 --- /dev/null +++ b/HACKING.md @@ -0,0 +1,148 @@ +# Personal-site | Production [Tested on server with Hyperbola GNU + Linux-libre] + +# Python dependencies + +- Django +- Pillow +- psycopg2-binary +- pytz + +# Production Installation + +1. Clone **Personal-site** () + + git clone https://gitlab.com/heckyel-ng/personal-site /path/to/site + +2. Run `virtualenv`. + + cd /path/to/personalsite && virtualenv ./venv/ + +3. Activate the virtualenv. + + source ./env/bin/activate + +4. Install dependencies through `pip`. + + pip install -r requirements_prod.txt + +# Configuration Postgres + +1. Logion as postgres + + sudo su - postgres + +2. Create base + + createdb namebase + +3. Create User (place a password for our user) + + createuser -P username + +4. Inside the database + + psql -d namebase + +5. Give permissions to the created user + + GRANT ALL PRIVILEGES ON DATABASE namebase TO username; + +# Conecting to Postgres + +1. Copy `settings.py.example` to `settings.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', + } + } + +2. Migrate changes. + + ./manage.py migrate + +3. Create superUSER + + ./manage.py createsuperuser + +# Run with Apache server and wsgi + +1. Install WSGI for Apache + + sudo pacman -S mod_wsgi + +2. 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 + +3. Create vhosts, for example: + + sudo emacs /etc/httpd/conf/extra/httpd-vhosts.conf + + and inside write the configuration, example: + + + + ServerAdmin example@dominio.com + ServerName example.com + ServerAlias example.com + + Alias /media /path/to/site/media/ + Alias /static /path/to/site/core/static/ + + Require all granted + + + + Require all granted + + + + + Require all granted + + + + WSGIDaemonProcess personalsite python-home=/path/to/site/venv python-path=/path/to/site + WSGIProcessGroup personalsite + WSGIScriptAlias / /path/to/site/wsgi.py + + + + +4. Replace `ALLOWED_HOSTS = []` + + on setting.py to: + + `ALLOWED_HOSTS = ["example.com", "localhost"]` + +5. Added on setting.py: + + STATIC_ROOT = '/path/to/site/core/static' + +6. Create the media/ directory + + cd /path/to/personalsite + + mkdir media/ + +7. Change Permition to media/ at group http + + sudo chown -R http:http media/ + +8. Restart Apache server + + sudo service httpd restart diff --git a/README.md b/README.md index 6dec8be..62e3f48 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ use virtualenv and pip to handle these. But if you insist on (Arch GNU/Linux) packages, you will probably want the following: - django -- python-psycopg2 - python-markdown - python-memcached