ATS server 已经部署OK,ATS_Web 工程打开浏览器登陆: http://172.28.137.66
1. 个人用户创建OK:
登陆使用 : ssh username@172.28.137.66, 初始密码:ats
root@psh-ats-02:/home# ls -al
total 40
drwxr-xr-x 10 root root 4096 Jun 26 10:46 .
drwxr-xr-x 23 root root 4096 Jun 25 10:42 ..
drwxr-xr-x 2 allen allen 4096 Jun 26 10:11 allen
drwxrwxr-x 3 root developer 4096 Jun 26 09:44 django
drwxr-xr-x 3 hwuser hwuser 4096 Jun 21 21:39 hwuser
drwxr-xr-x 2 kid kid 4096 Jun 26 10:46 kid
drwxr-xr-x 2 Luther Luther 4096 Jun 26 10:10 Luther
drwxr-xr-x 2 scott scott 4096 Jun 26 10:15 scott
drwxr-xr-x 2 xiaoqian xiaoqian 4096 Jun 26 10:33 xiaoqian
drwxr-xr-x 2 Yafeng Yafeng 4096 Jun 26 10:05 Yafeng
root@psh-ats-02:/home#
2. Linux Server 配置 (Django+Nginx+uWSGI)
(1) Python:
root@psh-ats-02:~# python3 -V
Python 3.7.3
root@psh-ats-02:~# python -V
Python 2.7.12
(2)pip
root@psh-ats-02:~# pip3 -V
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
root@psh-ats-02:~# pip -V
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
使用pip 安装module时,先设置代理: export http_proxy=http://proxy.intra:80
(3) Django:
Django 工程目录: /home/django/ATS_Web /data/django
root@psh-ats-02:/home/django/ATS_Web# ls -l
total 152
drwxrwxr-x 7 root developer 4096 Jun 25 17:03 Apps
drwxrwxr-x 4 root developer 4096 Jun 25 17:15 ATS_Web
drwxrwxr-x 2 root developer 4096 Jun 26 09:46 config
-rw-rwxr-- 1 root developer 139264 Jun 26 09:48 db.sqlite3
-rwxrwxr-x 1 root developer 627 Jun 25 17:03 manage.py
root@psh-ats-02:/home/django/ATS_Web#
(4) Nignx:(HTTP 代理服务器)
确保在server上一直开启
进程查看:ps ajx|grep nginx
进程关闭:killall -9 nginx
启动: systemctl start nginx 或 /etc/init.d/nginx start
停止: systemctl stop nginx 或 /etc/init.d/nginx stop
重启: systemctl restart nginx 或 /etc/init.d/nginx restart
配置文件: /etc/nginx/conf.d/ATS_Web_nginx.conf
(5) WSGI:(Django web服务器)
确保在server上一直开启
进程查看:ps ajx|grep uwsgi
进程关闭:killall -9 uwsgi
配置文件夹:
root@psh-ats-02:/home/django/ATS_Web/config# ls -l
total 72
-rw-rwxr-- 1 root developer 184 Jun 26 09:46 ATS_Web.xml
-rw-rwxr-- 1 root developer 372 Jun 26 09:46 uwsgi.ini ==>工程config文件,用于启动uwsgi
-rw-rwx--- 1 root developer 53555 Jun 26 10:44 uwsgi.log ==>uwsgi server log
-rw-rwxrw- 1 root developer 6 Jun 26 09:47 uwsgi.pid ==>uwsgi process id
root@psh-ats-02:/home/django/ATS_Web/config#
启动: uwsgi --ini uwsgi.ini 或 uwsgi -x ATS_Web.xml(不推荐) 在工程config目录下运行
停止: uwuwsgi --stop uwsgi.pid 在工程config目录下运行
重载: uwsgi --reload uwsgi.pid 在工程config目录下运行
手动调试命令:
socket模式: uwsgi --socket :8000 --chdir=/home/django/ATS_Web --module ATS_Web.wsgi
http模式 : uwsgi --http :8000 --chdir=/home/django/ATS_Web--module ATS_Web.wsgi
(6) 静态文件配置
搜集Django 工程静态文件:
root@psh-ats-02:~# cd /home/django/ATS_Web
root@psh-ats-02:/home/django/ATS_Web#
root@psh-ats-02:/home/django/ATS_Web# python3 manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
/home/django/ATS_Web/ATS_Web/static
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Found another file with the destination path 'js/jquery.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
0 static files copied to '/home/django/ATS_Web/ATS_Web/static', 229 unmodified.
root@psh-ats-02:/home/django/ATS_Web#
确保 Nignx config 文件的静态路径是 : /home/django/ATS_Web/ATS_Web/static
root@psh-ats-02:~# cat /etc/nginx/conf.d/ATS_Web_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server 127.0.0.1:8000; # for a web port socket
}
# configuration of the server
server {
listen 80;
server_name 172.28.137.66;
charset utf-8;
access_log /var/log/nginx/ATS_Web_access.log;
error_log /var/log/nginx/ATS_Web_error.log;
client_max_body_size 75M;
location /media {
alias /home/django/ATS_Web/media;
}
location /static/ {
alias /home/django/ATS_Web/ATS_Web/static/;
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}