当前位置:网站首页>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
边栏推荐
- Source code and some understanding of employee management system based on polymorphism
- Restart redis
- Error installing Mongo service 'mongodb server' on win10 failed to start
- Decision tree principle of machine learning
- Traversal of l2-006 tree (middle and later order determination binary tree & sequence traversal)
- The space between the left and right of the movie ticket seats is empty and cannot be selected
- Plug in for vscode
- Navicat failed to connect to Oracle Database: cannot load OCI DLL, 87: instant client package is
- Actual combat of industrial defect detection project (IV) -- ceramic defect detection based on hrnet
- L2-006 树的遍历(中后序确定二叉树&层序遍历)
猜你喜欢

Kubernetes - Introduction to actual combat

Devil cold rice 𞓜 078 devil answers the market in Shanghai and Nanjing; Communication and guidance; Winning the country and killing and screening; The purpose of making money; Change other people's op

L2-006 樹的遍曆(中後序確定二叉樹&層序遍曆)

windows MySQL8 zip安装

ele之Table表格的封装

工业互联网+危化安全生产综合管理平台怎样建

Deep q-network (dqn)

Practice of industrial defect detection project (III) -- Based on FPN_ PCB defect detection of tensorflow

Source code and some understanding of employee management system based on polymorphism

Linux Redis——Redis 数据库缓存服务
随机推荐
[unity3d] rolling barrage effect in live broadcasting room
字符串去掉空格问题
【Hcip】OSPF常用的6种LSA详解
JZ22 链表中倒数最后k个结点
tf. keras. layers. Inputlayer function
Winsock programming interface experiment: Ping
C language 171 Number of recent palindromes
Encapsulation of ele table
JS relearning
Niuke white moon race 6 [solution]
解决win7 中powershell挖矿占用CPU100%
Wepy learning record
VirtualBox virtual machine (Oracle VM)
JDBC JDBC
The express project changes the jade template to art template
Guangcheng cloud service can fill in a daily report regularly every day
Chapter VI project information management system summary
Log4j knowledge point record
Linux Redis——Redis 数据库缓存服务
ele之Table表格的封装
