当前位置:网站首页>Some problems encountered in setting Django pure interface, channel and MySQL on the pagoda panel
Some problems encountered in setting Django pure interface, channel and MySQL on the pagoda panel
2022-04-23 02:58:00 【haichao0991】
The project is the complete separation of the front and rear desks , The front desk address is http:// domain name :80 port , backstage api The interface address is :http:// domain name :7001,websocket The communication interface is :ws:// domain name :7002
One , Database import
After creating a new database and importing data , Discover remote navicat Unable to connect , Tips Lost connection to MySQL server at reading initial communication packet
solve : Set the database permissions so that everyone can access ( Only remote navicat During connection test , You can narrow the permission later )

Two , How to add python Of django project ?
Method : Using the pagoda python Project manager
Be careful : Pagoda only supports in centOS7+ Use , I wanted to use ubuntu, It can only be converted to centos 了 , But the difference is not big .
Pit point : Be sure not to choose 2.0 edition , choice 1.9 edition . I installed 2.0 I think the new version must be more powerful , It turned out that there was no pvenv command , The command is that the Baoda panel is installed python Project manager post configuration python Environmental , Provides a lot of convenient instructions
After installation, click the settings , Because the version I developed is higher ,centos The built-in python2.* no way ,( Mainly channel Need to have 3.4 Version above is supported async And so on ) So you need to install it first python3.* Version above , Here I installed j yes 3.8.3 edition

Enter from the pagoda panel to the terminal , Now you can use pyenv The command , Use pyenv versions View the current by python Project manager installed python All versions , Use pyenv shell Version number Command to modify the default python edition , Pictured 
Before that daphne The service , Always prompt for grammatical errors , Observe the error prompt and find that you don't know async keyword , So it has to be in python3.4+ Start in environment daphne, So the above settings are essential for me .
Upload the rest first python The whole content of the project , I installed it through the pagoda panel ftp Post upload , No use of pagoda file management . Upload it in python Add project to project manager , The specific configuration is as follows :

Upload with generated requuirements.txt, And check the installation dependency , The virtual environment can be automatically configured and started , At this time, the project shows that it is running , It means that it has succeeded , Otherwise, you can view the log or enter the virtual environment ( The method of entering the virtual environment is shown in the figure ) Start to view error messages .

Then I went through xshell The remote is turned on daphne service
3、 ... and 、 Configure the website
Although the project has a default 80 Port as front-end website ,7001 Port to do webAPI The server ,7002 Port to do websocket Receive and forward service ( Forwarding to daphne namely 127.0.0.1:7003), and daphne Service running on 7003 port , But you only need to configure one website ( I wanted to create it separately , However, after trying, it seems that only one website can be created for a domain name )

In the configuration file , My default will be 80 Configure as foreground website path ,7002 Forwarding by proxy , and 7001 Port by phython Project management has access to ( There are some questions here , stay python I didn't specify the domain name in the project management , Only the port is specified , But the front desk can really use the domain name :7001 Visit ), The details are as follows :
server
{
listen 80;
server_name www.youhostname.cn;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/ftpFrontUser/platform/platform/frontEnd/EXP_platform/myserver;
include enable-php-00.conf;
include /www/server/panel/vhost/rewrite/www.youhostname.cn.conf;
#REWRITE-END
# Forbidden files or directories
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
# One click application SSL Certificate validation directory related settings
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
access_log /www/wwwlogs/www.youhostname.cn.log;
error_log /www/wwwlogs/www.youhostname.cn.error.log;
}
server {
listen 7002;
server_name www.youhostname.cn;
location /ws{#ws
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
client_max_body_size 10m;
proxy_pass http://127.0.0.1:7003;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
The front page starts , It can be found that the interface can access , The front and rear ends have been opened . however websocket Communication is not yet available . Start below daphne service :
daphne -p 7003 Project name .asgi:application
But when ssh After the remote connection window closes , The service stops automatically , So here we use nohup command
nohup daphne -p 7003 Project name .asgi:application > /dev/null 2> /dev/null &
Turn off the ssh window ,websocket Communication is working properly !
版权声明
本文为[haichao0991]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220644528653.html
边栏推荐
- Cloud computing learning 1 - openstack cloud computing installation and deployment steps with pictures and texts (Xiandian 2.2)
- Liunx foundation - zabbix5 0 monitoring system installation and deployment
- 国产轻量级看板式Scrum敏捷项目管理工具
- Niuke white moon race 6 [solution]
- Error installing Mongo service 'mongodb server' on win10 failed to start
- Six very 6 computer driver managers: what software is good for driver upgrade? Recommended by the best computer driver management software abroad
- When using art template inheritance, compileerror: invalid or unexpected token generated
- Linux Redis ——Redis HA Sentinel 集群搭建详解 & Redis主从部署
- How can enterprises with major hazard installations ensure the completion of the digital construction task of double prevention mechanism by the end of the year
- Processes and threads
猜你喜欢

Linux redis - redis ha sentinel cluster construction details & redis master-slave deployment

Actual combat of industrial defect detection project (IV) -- ceramic defect detection based on hrnet

Innovation and management based on Scrum

基于多态的职工管理系统源码与一些理解

Kubernetes - Introduction to actual combat

Machine learning (Zhou Zhihua) Chapter 14 probability graph model

Traversée de l'arbre L2 - 006

tf. keras. layers. Timedistributed function

L2-006 树的遍历(中后序确定二叉树&层序遍历)

接口请求时间太长,jstack观察锁持有情况
随机推荐
First knowledge of C language ~ branch statements
ROP Emporium x86_64 7~8题
Interim summary (Introduction + application layer + transportation layer)
JSON data text
Get together to watch (detailed version) eat a few cents a day
[unity3d] rolling barrage effect in live broadcasting room
OCR recognition PDF file
How to build an integrated industrial Internet plus hazardous safety production management platform?
AC380V drop 5v12v24v200ma, UHV non isolated chip IC scheme
tf. keras. layers. Conv? D function
Winsock programming interface experiment: implementation of ipconfig
Learn regular expression options, assertions
Publish to NPM?
The problem of removing spaces from strings
基于Scrum进行创新和管理
Classification of technology selection (2022)
Jz76 delete duplicate nodes in linked list
JS relearning
Difference between relative path and absolute path (often asked in interview)
The way to conquer C language
