Install virtualenv
Install pip, virtualenv, virtualenvwrapper
sudo apt-get install -y python-pip python-virtualenv virtualenvwrapper
sudo apt-get install python-dev
Make virtualenv dirs
mkdir ~/virtualenvs
Add configure to .bashrc
export WORKON_HOME=~/virtualenvs
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=~/virtualenvs
Create virtualenv
mkvirtualenv mysite
workon mysite
Install nginx
sudo apt-get install nginx
Before add custom nginx file, just comment out default
nginx (/etc/nginx/site-avaliable/default
)
add nginx conf
In /etc/nginx/site-avaliable
, add your site nginx conf. (ex. mysite
)
server {
listen 80;
server_name your_server_name;
access_log /var/log/nginx/mysite_access.log;
error_log /var/log/nginx/mysite_error.log;
location / {
uwsgi_pass 0.0.0.0:3031;
include uwsgi_params;
}
location /media/ {
alias /home/username/mysite/media/;
}
location /static/ {
alias /home/username/mystie/static/;
}
}
ls
tn /etc/nginx/site-enable
sudo ln -s /etc/nginx/site-avaliable/mysite /etc/nginx/site-enable
Uwsgi settings
pip install uwsgi
If needed, install uwsgi-plugin-python
sudo apt-get install uwsgi-plugin-python
need more information, check SO answer
Make project uwsgi file in /etc/uwsgi/apps-avaliable
example of mysite.ini
[uwsgi]
vhost = true
plugins = python
socket = 0.0.0.0:3031
master = true
enable-threads = true
processes = 4
wsgi-file = /home/username/project/path_to/wsgi.py
virtualenv = /home/username/virtualenvs/project
chdir = /home/username/project
touch-reload = /home/username/project/reload
ls
to /etc/uwsgi/apps-enable
sudo ln -s /etc/uwsgi/apps-avaliable/mysite.ini /etc/uwsgi/apps-enable
Starting nginx and uwsgi
sudo service nginx start
sudo service uwsgi start
'backend > ubuntu' 카테고리의 다른 글
[book] The linux command line: working with commands - type, which, man, alias (0) | 2020.12.12 |
---|---|
Ubuntu 18.04 - python (django) server setup (0) | 2019.01.24 |
Ubuntu 16.04 pyenv, virtualenv, autoenv, postgres 설치하기 (0) | 2017.10.12 |
linux 공부 내용 (0) | 2017.06.04 |
리눅스 명령어: 리눅스 쉘 (.sh) 실행방법 (0) | 2017.03.16 |