OA 考勤与部署

OA考勤管理

考勤和其他功能不一样,是一个基于一张表的流程:

第一步:员工申请假条。

第二步:领导批复假条。

第三步:员工销假。

在这三步的过程当中,员工始终可以看到假条的状态。

OA部署

1、安装python环境

安装python环境保证linux服务器上的python版本不被影响。

python 3.7

OA 考勤与部署

 

 

OA 考勤与部署

1、安装依赖包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make libffi-devel wget -y

2、下载python环境

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

也可也载windows上下载好包,上传到服务器上,课上采用xshell 的xftp上传

OA 考勤与部署

 

注意,下载或者上传的文件存放到Linux默认的用户操作目录 /opt下

3、解压

tar -zxvf Python-3.7.7.tgz

OA 考勤与部署

 

4、配置安装

切入解压目录,使用安装包自带configure文件进行安装配置

[[email protected] opt]# cd Python-3.7.7
[[email protected] Python-3.7.7]# ls
aclocal.m4           configure.ac  Lib              Misc     PCbuild        setup.py
CODE_OF_CONDUCT.rst  Doc           LICENSE          Modules  Programs       Tools
config.guess         Grammar       m4               Objects  pyconfig.h.in
config.sub           Include       Mac              Parser   Python
configure            install-sh    Makefile.pre.in  PC       README.rst
[[email protected] Python-3.7.7]# ./configure prefix=/usr/local/python3

OA 考勤与部署

 

5、编译安装

make && make install

OA 考勤与部署

OA 考勤与部署

 

 

 

6、配置软连接

ln -s 目标文件绝对路径 /usr/bin
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

 

 

 

OA 考勤与部署

OA 考勤与部署

 

2、安装flask环境

将项目目录导入/opt/

OA 考勤与部署

OA 考勤与部署

 

[[email protected] opt]# cd BluePro/
[[email protected] BluePro]# 
[[email protected] BluePro]# ls
BluePro  db.sqlite  main.py  migrations  package.txt
[[email protected] BluePro]# pip3 install -r package.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

OA 考勤与部署

OA 考勤与部署

 

 

 

3、安装mysql数据库(可选)

4、安装uwsgi

开发过程当中,项目跑在python自带的轻量级服务器,这个服务器最多支撑200的并发,在工作当中,需要使用nginx服务器运行Flask项目,nginx服务器本身不支持Python的web框架,所以python服务首先跑在wusgi服务器上,当用户访问nginx服务器,然后转发到uwsgi上,实现项目运行,nginx比较uwsgi有更好的集群和调优性能。

OA 考勤与部署

 

uwsgi可以通过pip直接安装

pip3 install uwsgi -i https://pypi.tuna.tsinghua.edu.cn/simple
也需要创建软链接
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi

OA 考勤与部署

 

 

5、安装nginx

安装nginx步骤类似安装python

1、解压

[[email protected] opt]# tar -xvf nginx-1.12.2.tar 

OA 考勤与部署

 

2、配置安装

[[email protected] opt]# cd nginx-1.12.2
[[email protected] nginx-1.12.2]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[[email protected] nginx-1.12.2]# ./configure \
> #回车
checking for OS
..........

OA 考勤与部署

 

3、编译安装

make && make install

OA 考勤与部署

 

4、创建软连接

[[email protected] sbin]# pwd
/usr/local/nginx/sbin
[[email protected] sbin]# ls
nginx
[[email protected] sbin]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
​

OA 考勤与部署

 

[[email protected] sbin]# nginx
[[email protected] sbin]# systemctl stop firewalld
[[email protected] sbin]# 

OA 考勤与部署

 

 

6.编写和修改配置文件

配置uwsgi

在/opt/创建script目录存放uwsgi的配置文件,后缀为ini

[[email protected] sbin]# cd /opt/
[[email protected] opt]# mkdir script
[[email protected] opt]# cd script/
[[email protected] script]# touch uwsgi.ini
[[email protected] script]# yum install vim -y

编写uwsgi.ini

[uwsgi]
​
socket=127.0.0.1:5000
pythonpath=/opt/BluePro
module=main
wsgi-file=/opt/BluePro/main.py
callable=app
processes=4
threading=2
daemonize=/opt/script/uwsgi.log
​

配置nginx

cd /usr/local/nginx/conf
[[email protected] conf]# pwd
/usr/local/nginx/conf
[[email protected] conf]# ls
fastcgi.conf            koi-utf             nginx.conf           uwsgi_params
fastcgi.conf.default    koi-win             nginx.conf.default   uwsgi_params.default
fastcgi_params          mime.types          scgi_params          win-utf
fastcgi_params.default  mime.types.default  scgi_params.default

OA 考勤与部署

 

备份原始配置

[[email protected] conf]# cp nginx.conf nginx.conf.bak
[[email protected] conf]# ls
fastcgi.conf            koi-utf             nginx.conf          scgi_params.default
fastcgi.conf.default    koi-win             nginx.conf.bak      uwsgi_params
fastcgi_params          mime.types          nginx.conf.default  uwsgi_params.default
fastcgi_params.default  mime.types.default  scgi_params         win-utf
[[email protected] conf]#
​

修改nginx.conf

server {
    listen       80;
    server_name  OAPro;
​
    #charset koi8-r;
​
    #access_log  logs/host.access.log  main;
    access_log  logs/host.access.log;
    error_log  logs/host.error.log;
​
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:5000;
        uwsgi_param UWSGI_CHDIR /opt/BluePro;
        uwsgi_param UWSGI_SCRIPT main:app;
    }

 

OA 考勤与部署

7.启动项目

先启动uwsgi

[[email protected] script]# pwd
/opt/script
[[email protected] script]# ls
uwsgi.ini
[[email protected] script]# uwsgi --ini uwsgi.ini 
[uWSGI] getting INI configuration from uwsgi.ini
[[email protected] script]# ls
uwsgi.ini  uwsgi.log
[[email protected] script]# 
​

OA 考勤与部署

 

在启动nginx

[[email protected] BluePro]# pkill -9 nginx
[[email protected] BluePro]# nginx
[[email protected] BluePro]# 

OA 考勤与部署

 

8、测试效果

OA 考勤与部署

 

 

 

 

 

 

 

 

 

 

 

 

相关文章: