当前位置:网站首页>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
边栏推荐
- The interface request takes too long. Jstack observes the lock holding
- Log cutting - build a remote log collection server
- 解决win7 中powershell挖矿占用CPU100%
- Close the computer port
- tf. keras. layers. Density function
- Essential qualities of advanced programmers
- Airtrack cracking wireless network password (Dictionary running method)
- Linux Redis ——Redis HA Sentinel 集群搭建详解 & Redis主从部署
- Practice of industrial defect detection project (III) -- Based on FPN_ PCB defect detection of tensorflow
- ROP Emporium x86_64 7~8题
猜你喜欢

Servlet template engine usage example

Configuring Apache Web services for servers such as Tianyi cloud

国产轻量级看板式Scrum敏捷项目管理工具

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

tf. keras. layers. Timedistributed function

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

Kubernetes study notes
![Introduction to ACM [TSP problem]](/img/9f/4e3592542d989b2fbb6d82f7f2fbd2.png)
Introduction to ACM [TSP problem]

JS learning notes

Windows MySQL 8 zip installation
随机推荐
OCR识别PDF文件
Linux redis - redis ha sentinel cluster construction details & redis master-slave deployment
Chapter VII project communication management of information system project manager summary
Leangoo brain map - shared multi person collaborative mind mapping tool
eventBus
JS relearning
Depth deterministic strategy gradient (ddpg)
Huashu "deep learning" and code implementation: 01 Linear Algebra: basic concepts + code implementation basic operations
ele之Table表格的封装
Error installing Mongo service 'mongodb server' on win10 failed to start
mysql function函数语法
《信息系统项目管理师总结》第六章 项目人力资源管理
leangoo脑图-共享式多人协作思维导图工具分享
Chapter IV project cost management of information system project manager summary
Linux Redis ——Redis HA Sentinel 集群搭建详解 & Redis主从部署
ROP Emporium x86_ 64 7 ~ 8 questions
If MySQL / SQL server judges that the table or temporary table exists, it will be deleted
The problem of removing spaces from strings
The express project changes the jade template to art template
AC & A2C & A3C
