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,64 +11,89 @@
## 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
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
1. List database
- List database
psql -l
```console
$ psql -l
```
2. Delete database
- Delete database
dropdb namebase
```console
$ dropdb namebase
```
## 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
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:
```python
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
@ -79,37 +104,50 @@
'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
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:
```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:
@ -142,43 +180,49 @@
</VirtualHost>
</IfModule>
4. Replace `ALLOWED_HOSTS = []`
- Replace `ALLOWED_HOSTS = []`
on setting.py to:
ALLOWED_HOSTS = ["example.com", "localhost"]
5. Added on setting.py:
- Added on setting.py:
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
7. Create the media/ directory
```
cd /path/to/personalsite
```console
$ python manage.py collectstatic
```
```
mkdir media/
- Create the media/ directory
```console
$ cd /path/to/personalsite
```
8. Change Permition to media/ at group http
```console
$ mkdir media/
```
sudo chown -R http:http media/
- Change Permition to media/ at group http
9. Restart Apache server
```console
$ sudo chown -R http:http media/
```
sudo service httpd restart
- Restart Apache server
10. Done!
```console
$ sudo rc-service httpd restart
```
- Done!
## Security on settings.py [SSL, HTTPS, COOKIE, etc]
```
```bash
# security.W004
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True

View File

@ -31,41 +31,41 @@ packages, you will probably want the following:
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`.
cd personal-site && virtualenv ./venv/
$ cd personal-site && virtualenv ./venv/
3. Activate the virtualenv.
source ./venv/bin/activate
$ source ./venv/bin/activate
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.
Make sure to uncomment the appropriate database section (either sqlite or
PostgreSQL).
cp -v personalsite/settings.py.example personalsite/settings.py
$ cp -v personalsite/settings.py.example personalsite/settings.py
6. Check syntax.
python manage.py check --deploy
$ python manage.py check --deploy
7. Migrate changes.
python manage.py migrate
$ python manage.py migrate
8. Create superUSER
python manage.py createsuperuser
$ python manage.py createsuperuser
9. Use the following commands to start a service instance
python manage.py runserver
$ python manage.py runserver
## Production Installation