開放指定的端口:firewall-cmd --zone=public --add-port=端口號/tcp --permanenthtml
須要注意的是:開放端口以後須要重啓防火牆才能生效
依賴安裝java
yum install python3-devel zlib-devel mysql-devel libffi-devel bzip2-devel openssl-devel java wget gcc
安裝nginxnode
yum install nginx
安裝redis和mysqlpython
yum install mysql-server yum install redis
安裝python進程管理工具supervisormysql
yum install python3-devel zlib-devel mysql-devel libffi-devel bzip2-devel openssl-devel java wget gcc
設置開機啓動nginx
systemctl enable redis mysqld nginx supervisord
注意:web
- mysql安裝以後默認不會啓動,須要使用systemctl start mysqld.service來啓動,或者mysqld.service替換爲mysqld
- 設置開機自啓動時是mysqld和supervisord,不是mysql和supervisor
安裝python3.7redis
把python3和pip3軟鏈接到/usr/bin上:sql
問題:使用pip3 install -r requirements.txt安裝依賴時,報錯:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ifh_bc24/cryptography/
解決方法:命令行pip3 install --upgrade setuptools,而後重試
nginx配置文件瀏覽器
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user root; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. #include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; upstream uwsgi_backend { # http請求轉發配置 server localhost:8888; } upstream channels-backend { # websocket請求轉發配置 server localhost:8000; } server { listen 80 default_server; listen [::]:80 default_server; server_name www.ejpro.top; # 顯示在瀏覽器上的名稱 charset utf-8; client_max_body_size 75M; #客戶端請求體最大的限制 # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; ##### 靜態文件設置 location /static/ { root /home/tourism; # static文件所在的目錄路徑 } location /media/ { root /home/tourism; # media文件所在的目錄路徑 } #### 動態轉發請求 location / { uwsgi_pass 127.0.0.1:8001; include /etc/nginx/uwsgi_params; # 指向的是nginx,Django自己沒有該文件 } } }
注意事項:
靜態文件路徑配置,static和media的配置路徑都只能寫到上一層,不能包含static和media這一層,這一點必需要注意,不然會出現以下錯誤:
[error] 14635#0: *49 open() "/home/tourism/static/static/admin/simpleui-x/particles/particles.js" # 多寫了一層static
配置文件
[uwsgi] # Django manage.py 所在文件夾路徑 #Django項目源碼目錄 chdir = /home/tourism # Django系統的uwsgi,若是不記得能夠從settings.py文件中WSGI_APPLICATION查看 module = project.wsgi:application # 啓用master進程管理 master = true # 綁定的 UNIX socket socket = 127.0.0.1:8888 # uwsgi的進程數 processes = 4 # 重啓進行耗時超過30秒就關閉 harakiri = 30 # 最大請求處理數,以後從新生成進程 max-requests = 5000 # 退出時清理環境 vacuum = true # socket socket = 127.0.0.1:8001 # uid uid = 1000 # gid gid = 2000 # pidfile路徑 pidfile = /home/tourism/deploy/sub/master.pid # deamonize日誌文件路徑 deamonize = /home/tourism/deploy/sub/tourism.log # 當服務器關閉或退出時是否清除pidfile和deamonize文件 vacuum=True static-map = /static = /home/tourism/static
須要配置static-map = /static = /home/tourism/static
解決辦法: