django 2+uwsgi+nginx 서버 Ubuntu 16.04 에 온라인 배치
1.Terminal 단말 기 를 열 고 다음 명령 을 실행 하 며 프로젝트 에 필요 한 의존 패 키 지 를 파일 에 기록 합 니 다.
pip freeze >requirements.txt

2.프로젝트 폴 더→오른쪽 단 추→압축 파일 추가,zip 패키지 로 압축


3.소프트웨어 준비
1.xshell(원 격 조작 서버 에 사용)2.FileZilla(클 라 이언 트 에서 프로젝트 패 키 지 를 서버 에 업로드 하 는 데 사용)3.Navicat 12(데이터베이스 동기 화 에 사용)
4.환경 구름
서버/클 라 우 드 호스트:경 동 운
(클 라 우 드 서 비 스 는 큰 공장 을 선택해 야 합 니 다.저도 비교적 작은 공장 의 클 라 우 드 서 비 스 를 해 봤 습 니 다.어느 곳 이 라 고 말 하지 않 았 습 니 다.와,정말 구덩이 입 니 다.각종 잘못 보고 가 있어 서 아무것도 설치 할 수 없습니다.우정 은 클 라 우 드 서 비 스 는 텐 센트 클 라 우 드,아 리 클 라 우 드,바 이 두 클 라 우 드,금 산 운,경 동 운,왕 이 운 등 중에서 선택해 야 한 다 는 것 을 일 깨 워 준다.외국 에 서 는 아마 존 과 같 습 니 다.클 라 우 드 컴 퓨 팅 기술 이 국내 클 라 우 드 보다 앞 설 수 있 고 가격 도 공정 할 수 있 지만 어떤 일 들 은 여러분 이 알 아야 할 것 이 있 습 니 다.그래서 비 싼 것 이 좀 비 싼 것 인지 국내 것 을 선택 하 세 요.)
시스템:Ubuntu 16.04 64 비트
2.기본 설정
1.xshell 링크 클 라 우 드 서버/클 라 우 드 호스트 시스템(클 라 우 드 서버 와 클 라 우 드 호스트 는 여기 서 개념 차이 가 많 지 않 습 니 다.뒤에 클 라 우 드 서버 라 고 합 니 다)1.xshell→[파일]→[새로 만 들 기]를 열 고 클 라 우 드 서버 의 네트워크 ip 을 입력 하 십시오.

2.방금 만 든 세 션 을 선택 하고[연결]을 누 르 십시오.

3.로그 인 사용자 이름 입력:root

4.로그 인 비밀번호 입력

5.연결 성공

2.새 사용자 ubuntu
1.명령 실행
adduser ubuntu
#
#
#
#
#
#
# ,
y+
cd /home #
ls # , ubuntu

2.사용자 ubuntu 전환

3.일반 사용자 ubuntu 에 권한 추가
# root
su root
# root
chmod u+w /etc/sudoers # sudoers
vim /etc/sudoers# sudoers, root ALL=(ALL) ALL, ubuntu ALL=(ALL) NOPASSWD: ALL
chmod u-w /etc/sudoers# sudoers
su ubuntu # ubuntu
3.동기 화 데이터베이스1.mysql 데이터베이스 설치
sudo apt-get install mysql-server -y
# :( , , )
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev -y
2.원 격 연결 권한 설정
su root # root
#root
vim /etc/mysql/mysql.conf.d/mysqld.cnf
# , i ,
# , bind-address = 127.0.0.1
# , Esc , :wq
mysql -u root -p
# ( ), mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
quit
# Navicat , :
fuser -k 3306/tcp
# ,
3.Navicat 12 동기 데이터베이스 사용1.연결 만 들 기

2.로 컬 연결 만 들 기

3.서버 링크 만 들 기

4.전송 데이터베이스


그리고[시작]을 눌 러 서 100%전 달 될 때 까지 기다 리 세 요.

5.데이터베이스 업로드 성공 여부 확인
mysql -u root -p
show databases;#
quit #

4.원 격 연결 데이터베이스 권한 취소
vim /etc/mysql/mysql.conf.d/mysqld.cnf
# , i ,
# , bind-address = 127.0.0.1
# , Esc , :wq
4.항목 업로드
su ubuntu # ubuntu
1.FileZilla 로 프로젝트 zip 패키지 업로드

2.압축 풀기 프로젝트 zip 패키지
sudo apt install unzip
unzip xueyiwang.zip

5.Python 3.6 설치
sudo add-apt-repository ppa:fkrull/deadsnakes #
#
sudo apt-get install python-software-properties -y
sudo apt-get update
sudo apt-get install python3.6-dev python3.6-venv -y
sudo apt install python-pip -y
6.가상 환경 설정1.의존 패키지 설치
python3.6 -m venv env36
# , python3.6 , env36, 3.6.2
. env36/bin/activate
#
# deactivate
cd xueyiwang
pip3 install -r requirments.txt
# , requirments.txt, , pip freeze > requirments.txt
# , low , ,bat ,
# pip , ,

2.settings.py 수정
cd xueyiwang
vim settings.py

# settings.py , i ,
#
ALLOWED_HOSTS = [' ip']
#
STATIC_ROOT=os.path.join(BASE_DIR,"static/")
# Esc , :wq


3.테스트 실행 항목
cd ..
python manage.py runserver 0.0.0.0:8000
# : ip+8000
# !
#ctrl+c


7.가상 환경 에 uwsgi 설치
1.설치
cd ~
pip3 install uwsgi

2.설치 성공 여부 확인
cd xueyiwang
uwsgi --http :8000 --module xueyiwang.wsgi
# uwsgi ,
#ctrl+C
#fuser -k 8000/tcp
# 8000
# ip+8000 , uwsgi


8.설치 설정 nginx
1.nginx 설치
cd ..
sudo apt install nginx -y

2.uwsgi 와 nginx 연결 설정
cd xueyiwang
cp /etc/nginx/uwsgi_params . # ,
# ~
cd ..

3.uwsgi.ini 설정
vim uwsgi.ini
# uwsgi.ini, i , , ( i , )
# ,Esc , wq+ , 。
[uwsgi]
chdir=/home/ubuntu/xueyiwang
module=xueyiwang.wsgi:application
home=/home/ubuntu/env36
master=true
processes=10
socket=:8001
chmod-socket = 666
vacuum=true

4.nginx 설정
#cd
vim xueyiwang_nginx.conf
# nginx.conf
# , i ,
#
upstream django {
# server unix:/root/xueyiwang/xueyiwang.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name .example.com; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/ubuntu/xueyiwang/media; # your Django project's media files - amend as required
}
location /static {
alias /home/ubuntu/xueyiwang/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/ubuntu/xueyiwang/uwsgi_params; # the uwsgi_params file you installed
}
}

5.소프트 링크 만 들 기
sudo ln -s /home/ubuntu/xueyiwang/xueyiwang_nginx.conf /etc/nginx/sites-enabled/

6.핸드폰 정적 파일
#cd
python manage.py collectstatic
#yes

7.최종 테스트
# settings.py
DEBUG = False
cd ~
sudo service nginx restart
# nginx
# uwsgi
uwsgi --ini uwsgi.ini
# http:// ip:8000


# ip+:8000 , , , nginx 。

이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
django 2+uwsgi+nginx 서버 Ubuntu 16.04 에 온라인 배치1.사전 준비 1.Terminal 단말 기 를 열 고 다음 명령 을 실행 하 며 프로젝트 에 필요 한 의존 패 키 지 를 파일 에 기록 합 니 다. 3.소프트웨어 준비 (클 라 우 드 서 비 스 는 큰 공장 을 선택...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.