update documentation

This commit is contained in:
Jesús 2021-05-30 18:17:24 -05:00
parent 197586a2d8
commit f6b39a2b4c
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766
2 changed files with 120 additions and 76 deletions

View File

@ -11,105 +11,143 @@
## Production Installation ## Production Installation
1. Clone **Personal-site** - Clone **Personal-site**
git clone https://libregit.org/heckyel/personal-site.git ```console
$ git clone https://libregit.org/heckyel/personal-site.git
```
2. Run `virtualenv`. - Run `virtualenv`.
cd personal-site && virtualenv ./venv/ ```console
$ cd personal-site && virtualenv ./venv/
```
3. Activate the virtualenv. - Activate the virtualenv.
source ./venv/bin/activate ```console
$ source ./venv/bin/activate
```
4. Install dependencies through `pip`. - Install dependencies through `pip`.
pip install -r requirements_prod.txt ```console
$ pip install -r requirements_prod.txt
```
## Configuration Postgres ## Configuration Postgres
1. Login as postgres - Login as postgres
sudo su - postgres ```console
$ sudo su - postgres
```
2. Create base - Create base
createdb namebase ```console
$ createdb namebase
```
3. Create User (place a password for our user) - Create User (place a password for our user)
createuser -P username ```console
$ createuser -P username
```
4. Inside the database - Inside the database
psql -d namebase ```console
$ psql -d namebase
```
5. Give permissions to the created user - Give permissions to the created user
GRANT ALL PRIVILEGES ON DATABASE namebase TO username; ```console
$ GRANT ALL PRIVILEGES ON DATABASE namebase TO username;
```
## Tips of Postgres ## Tips of Postgres
1. List database - List database
psql -l ```console
$ psql -l
```
2. Delete database - Delete database
dropdb namebase ```console
$ dropdb namebase
```
## Conecting to Postgres ## Conecting to Postgres
1. Copy `settings.py.example` to `settings.py` and modify. - Copy `settings.py.example` to `settings.py` and modify.
Make sure to uncomment the appropriate database section (either sqlite or Make sure to uncomment the appropriate database section (either sqlite or
PostgreSQL). PostgreSQL).
`cp -v personalsite/settings.py.example personalsite/settings.py` ```console
$ cp -v personalsite/settings.py.example personalsite/settings.py
```
Replace sqlite configuartion to postgres, example: Replace sqlite configuartion to postgres, example:
DATABASES = { ```python
'default': { DATABASES = {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'default': {
'NAME': 'namebase', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'username', 'NAME': 'namebase',
'PASSWORD': 'pass', 'USER': 'username',
'HOST': '127.0.0.1', 'PASSWORD': 'pass',
'PORT': '5432', 'HOST': '127.0.0.1',
} 'PORT': '5432',
} }
}
```
2. Check syntax. - Check syntax.
python manage.py check --deploy ```console
$ python manage.py check --deploy
```
3. Migrate changes. - Migrate changes.
python manage.py migrate ```console
$ python manage.py migrate
```
4. Create superUSER - Create superUSER
python manage.py createsuperuser ```console
$ python manage.py createsuperuser
```
## Run with Apache server and wsgi ## Run with Apache server and wsgi
1. Install WSGI for Apache - Install WSGI for Apache
sudo pacman -S mod_wsgi ```console
$ sudo pacman -S mod_wsgi
```
2. To install mod_wsgi, add the following line in `httpd.conf`, example: - To install mod_wsgi, add the following line in `httpd.conf`, example:
sudo nano /etc/httpd/conf/httpd.conf ```console
$ sudo nano -w /etc/httpd/conf/httpd.conf
```
Added line: Added line:
LoadModule wsgi_module modules/mod_wsgi.so ```apacheconf
LoadModule wsgi_module modules/mod_wsgi.so
```
3. Create vhosts, for example: - Create vhosts, for example:
sudo emacs /etc/httpd/conf/extra/httpd-vhosts.conf $ sudo nano -w /etc/httpd/conf/extra/httpd-vhosts.conf
and inside write the configuration, example: and inside write the configuration, example:
@ -142,43 +180,49 @@
</VirtualHost> </VirtualHost>
</IfModule> </IfModule>
4. Replace `ALLOWED_HOSTS = []` - Replace `ALLOWED_HOSTS = []`
on setting.py to: on setting.py to:
ALLOWED_HOSTS = ["example.com", "localhost"] ALLOWED_HOSTS = ["example.com", "localhost"]
5. Added on setting.py: - Added on setting.py:
STATIC_ROOT = '/path/to/site/core/static' STATIC_ROOT = '/path/to/site/core/static'
6. Generated files static of Admin Django (you must be inside the virtualenv). - Generated files static of Admin Django (you must be inside the virtualenv).
python manage.py collectstatic ```console
$ python manage.py collectstatic
```
7. Create the media/ directory - Create the media/ directory
``` ```console
cd /path/to/personalsite $ cd /path/to/personalsite
``` ```
``` ```console
mkdir media/ $ mkdir media/
``` ```
8. Change Permition to media/ at group http - Change Permition to media/ at group http
sudo chown -R http:http media/ ```console
$ sudo chown -R http:http media/
```
9. Restart Apache server - Restart Apache server
sudo service httpd restart ```console
$ sudo rc-service httpd restart
```
10. Done! - Done!
## Security on settings.py [SSL, HTTPS, COOKIE, etc] ## Security on settings.py [SSL, HTTPS, COOKIE, etc]
``` ```bash
# security.W004 # security.W004
SECURE_HSTS_SECONDS = 31536000 SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_INCLUDE_SUBDOMAINS = True

View File

@ -31,41 +31,41 @@ packages, you will probably want the following:
1. Clone personal-site 1. Clone personal-site
git clone https://libregit.org/heckyel/personal-site.git $ git clone https://libregit.org/heckyel/personal-site.git
2. Run `virtualenv`. 2. Run `virtualenv`.
cd personal-site && virtualenv ./venv/ $ cd personal-site && virtualenv ./venv/
3. Activate the virtualenv. 3. Activate the virtualenv.
source ./venv/bin/activate $ source ./venv/bin/activate
4. Install dependencies through `pip`. 4. Install dependencies through `pip`.
pip install -r requirements.txt $ pip install -r requirements.txt
5. Copy `settings.py.example` to `settings.py` and modify. 5. Copy `settings.py.example` to `settings.py` and modify.
Make sure to uncomment the appropriate database section (either sqlite or Make sure to uncomment the appropriate database section (either sqlite or
PostgreSQL). PostgreSQL).
cp -v personalsite/settings.py.example personalsite/settings.py $ cp -v personalsite/settings.py.example personalsite/settings.py
6. Check syntax. 6. Check syntax.
python manage.py check --deploy $ python manage.py check --deploy
7. Migrate changes. 7. Migrate changes.
python manage.py migrate $ python manage.py migrate
8. Create superUSER 8. Create superUSER
python manage.py createsuperuser $ python manage.py createsuperuser
9. Use the following commands to start a service instance 9. Use the following commands to start a service instance
python manage.py runserver $ python manage.py runserver
## Production Installation ## Production Installation