当前位置:网站首页>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
边栏推荐
- 重大危险源企业如何保障年底前完成双预防机制数字化建设任务
- ROP Emporium x86_ 64 7 ~ 8 questions
- Fashion MNIST dataset classification training
- Linux redis - redis ha sentinel cluster construction details & redis master-slave deployment
- JS relearning
- Android 高阶面试必问:全局业务和项目的架构设计与重构
- Navicat failed to connect to Oracle Database: cannot load OCI DLL, 87: instant client package is
- Introduction to ACM [inclusion exclusion theorem]
- The penultimate K nodes in jz22 linked list
- Store consumption SMS notification template
猜你喜欢

LeetCode 1450 - 1453

tf. keras. layers. Embedding function
![Introduction to ACM [TSP problem]](/img/9f/4e3592542d989b2fbb6d82f7f2fbd2.png)
Introduction to ACM [TSP problem]

Traversée de l'arbre L2 - 006

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

Opencv fills the rectangle with a transparent color

Huawei machine test question -- deformation of hj53 Yang Hui triangle

Practical combat of industrial defect detection project (II) -- steel surface defect detection based on deep learning framework yolov5

Android 高阶面试必问:全局业务和项目的架构设计与重构

grain rain
随机推荐
Essential qualities of advanced programmers
Reverse a linked list < difficulty coefficient >
L2-006 树的遍历(中后序确定二叉树&层序遍历)
Shell script learning notes -- shell operation on files sed
The space between the left and right of the movie ticket seats is empty and cannot be selected
The penultimate K nodes in jz22 linked list
JS relearning
Gavl021, gavl281, AC220V to 5v200ma small volume non isolated chip scheme
Slave should be able to synchronize with the master in tests/integration/replication-psync. tcl
tf. keras. layers. MaxPooling? D function
Windows MySQL 8 zip installation
Store consumption SMS notification template
OCR识别PDF文件
Guangcheng cloud service can fill in a daily report regularly every day
The way to conquer C language
Traversal of l2-006 tree (middle and later order determination binary tree & sequence traversal)
Planning code ROS migration POMDP prediction planning (I)
Sonic cloud real machine tutorial
基于ele封装下拉菜单等组件
JZ35 replication of complex linked list
