update documentation
This commit is contained in:
parent
197586a2d8
commit
f6b39a2b4c
158
HACKING.md
158
HACKING.md
@ -11,65 +11,90 @@
|
||||
|
||||
## 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:
|
||||
Replace sqlite configuartion to postgres, example:
|
||||
|
||||
DATABASES = {
|
||||
```python
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'namebase',
|
||||
@ -78,38 +103,51 @@
|
||||
'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
|
||||
|
||||
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:
|
||||
|
||||
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:
|
||||
|
||||
@ -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
|
||||
```console
|
||||
$ python manage.py collectstatic
|
||||
```
|
||||
|
||||
7. Create the media/ directory
|
||||
- Create the media/ directory
|
||||
|
||||
```
|
||||
cd /path/to/personalsite
|
||||
```
|
||||
```console
|
||||
$ cd /path/to/personalsite
|
||||
```
|
||||
|
||||
```
|
||||
mkdir media/
|
||||
```
|
||||
```console
|
||||
$ 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]
|
||||
|
||||
```
|
||||
```bash
|
||||
# security.W004
|
||||
SECURE_HSTS_SECONDS = 31536000
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||
|
18
README.md
18
README.md
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user