练手项目
停车场系统
- 安装centos7
- 解压安装python3 tar -xf Python-3.5.6.tar.xz 解压缩xz压缩包
- 源码编译安装
- yum groupinstall 'Development Tools'
- yum install -y ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
- mkdir /usr/local/python3
- cd Python-3.5.6
- 编译配置 ./configure --prefix=/usr/local/python3 --enable-optimizations
- 编译和安装 make && make install
- 在/usr/bin创建python3的快捷方式链接,方便在系统任何目录运行python3
- ln -s /usr/local/python3/bin/python3 /usr/bin/python3
- ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
- 查看版本号 python3 -V
- mysql安装
- 安装命令 yum -y install mariadb mariadb-server
- 安装完成MariaDB,首先启动MariaDB systemctl start mariadb
- 设置开机启动 systemctl enable mariadb
- 取消开机启动 systemctl disable mariadb
- 项目包处理
- 切换到/opt
- 解压ParkingSys-master.zip代码包到当前目录
- 进入源码目录 /opt/ParkingSys-master/ParkingSysApi
- 安装程序依赖包
- pip3 install -r requirements.txt
- pip3 install -r requirements.txt --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org
- 创建数据库
- 进入数据库使用mysql -u root -p CREATE DATABASE parking CHARSET=UTF8
- 找到config.py 数据的密码设定好,如果没有密码把 :123456 去除掉
- 启动停车场系统
- 切换目录 cd /opt/ParkingSys-master
- 启动停车场系统 执行 python3 apprun.py &
- navicat客户端连接数据库,更改mysql数据权限表
1.进入数据库 mysql -u root -p
2. use mysql;
3. update user set Host = '%' where User = 'root' and Host = 'localhost.localdomain'; - 重新启动数据库 systemctl restart mariadb
- 关闭防火墙(已经关闭的时候可以忽略) systemctl stop firewalld systemctl disable firewalld
国家电网
- 安装centos7操作系统
- 检查网络,配置网络参数
- ip addr 查看IP地址
- /etc/sysconfig/network-scripts/ifcfg-ens33网卡配置文件,将onboot=no改为yesIPV6开头的配置项全部#注释掉
- 重启操作系统reboot systemctl restart network
- 改为桥接模式继续重启 systemctl restart network
- /opt目录下安装JDK
- tar -zxvf jdk-8u144-linux-x64.tar.gz
- vi /etc/profile,在profile下添加如下:
- export JAVA_HOME=/opt/jdk1.8.0_144
- export PATH=(JAVA_HOME/bin:)PATH
- export CLASSPATH=.:(JAVA_HOME/lib/dt.jar:)JAVA_HOME/lib/tools.jar
- source /etc/profile
- java -version 检查jdk安装是否完好
- 在添加环境的时候,执行之后,导致vi命令不能使用的时候使用如下命令 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/us
- /opt 安装tomcat中间件
- tar zxvf apache-tomcat-7.0.82.tar.gz
- 目录apache-tomcat-7.0.82名称修改为tomcat
- 命令关闭防火墙(先查看是否关闭,已经关闭忽略此步骤) systemctl stop firewalld #停止firewall systemctl disable firewalld #禁止firewall开机启动
- 启动tomcat tomcat/bin/startup.sh
- 用浏览器访问,http://
:8080 测试tomcat安装是否完好
- 安装mysql数据库
- yum -y install mariadb mariadb-server
- 启动MariaDB systemctl start mariadb
- 设置开机启动 systemctl enable mariadb
- 修改数据库密码(可以不做)mariadb root用户,密码默认为空 mysql_secure_installation
- 部署应用
- 将KBMS.war拷贝到tomcat/webapps/目录下
- 使用脚本创建数据库以及表 mysql -u root -p 以root用户登录数据库 mysql
- source /opt/KBMS.sql
- 配置数据库连接
- 将KBMS.xml数据库配置文件拷贝到tomcat/conf/Catalina/localhost/并且打开修改数据库密码为空 vi tomcat/conf/Catalina/localhost/KBMS.xml→password=""
- 打开/etc/my.cnf 在[mysqld]下添加skip-grant-tables
- 重新启动mysql
- systemctl stop mariadb
- systemctl start mariadb
- 重新启动tomcat
- tomcat/bin/shutdown.sh
- tomcat/bin/startup.sh
- 浏览器打开应用 http://{ip地址}:8080/KBMS
- 修改tomcat默认端口号(8080)tomcat/conf/server.xml 将8080修改为80
- 浏览器再次打开应用 http://{ip地址}/KBMS
- 查看tomcat日志
- 日志所在位置在 tomcat/logs/catalina.out
- 根据error/excption 去查找错误内容
- mysql默认端口号是3306 oracle 默认端口号是1521