01. Linux项目实战
2024年10月28日大约 4 分钟
01. Linux项目实战
1. 环境部署准备
1. 软件工具准备
VMWare虚拟机
- 在本机上安装好Vmware虚拟机
- 在虚拟机上安装并运行Linux系统
注意: 实际工具中使用云服务器
2. 远程连接测试
远程连接工具
- 在本机上安装好远程连接工具 (xshell/putty)
- 通过远程连接工具连接到虚拟机
软件工具准备-关闭linux上的防火墙
停止firewall服务
- systemctl stop firewalld
查看防火墙状态
- systemctl status firewalld
禁止firewall开机启动
- systemctl disable firewalld
3. 远程连接测试-查看虚拟机IP地址
在linux虚拟机中输入ifconfig命令,查看对应的IP地址

4. 远程连接测试-检测本机与虚拟机是否连通
在本机DOS命令中输入: ping 192.168.10.31 (linux虚拟机的IP地址)

5. 远程连接测试-通过远程工具连接linux服务器
1、打开XShell工具,新建

2、配置属性

3、双击会话,验证用户名和密码


6. 常见问题处理
linux虚拟机获取不到IP地址
解决方案一: 检查vmware服务在DOS下输入 services.msc打开应用 服务,确认vmware服务都处于”正在运行”
image-20240730113154017 解决方案二: 查看wmware网络编辑器检查虚拟机网络编辑器(VMware:编辑-->虚拟网络编辑器)检查VMnet8类型是否是NAT模式(建议是NAT模式)确认将该虚拟机连接到网络并开启DHCP服务

2. 虚拟机网络配置说明
3. 环境部署
1. 项目技术架构介绍


lnmp: linux + nginx + mysql + php
lamp: linux + apache + mysql + php
2. CentOs软件安装方式
- yum在线安装
- 必须连互联网能够解决依赖问题
- 源码编译安装
- 自己下载源码并修改编译安装
- 自已解决依赖
- rpm安装
- 自己下载rmp包
- 自己解决依赖
3. 安装必备的软件
1. 手动安装服务
2. 集成环境安装(推荐)
4. Mysql数据库实战
1. 熟悉数据库表设计
- 熟悉用户信息表
- 用户信息表: tp_users
- 用户地址信息表: tp_user_address
- 熟悉商品信息表
- 商品信息表: tp_goods
- 商品分类信息表: tp_goods_category
- 商品图片信息表: tp_goods_image
- 熟悉订单信息表
- 订单信息表: tp_order
- 订单商品信息表: tp_order_goods
- 购物车表: tp_cart
2. 数据查询演练
1. 查询Tpshop的商品分类信息

在数据库中查询出商品分类类目
-- 在数据库中查询出商品分类类目 -- 找所有的 select mobile_name from tp_goods_category -- 显示的 is_show 为1, 不显示为0 select mobile_name, is_show from tp_goods_category where parent_id = 0 select mobile_name from tp_goods_category where parent_id=0 and is_show = 1
2. 查询出手机数码的分类类目
-- 查询出手机的分类类目
-- 手机的id就是31 如何找出 31
select name from tp_goods_category where parent_id = 31
select id from tp_goods_category where mobile_name = '手机'
-- 上一步的子查询充当条件
select name from tp_goods_category where parent_id = (
select id from tp_goods_category where mobile_name = '手机'
)
-- 查询出手机数码的分类类目
-- 如何找出32
select name from tp_goods_category where parent_id = 32
-- 手机通讯的id就是32
select id from tp_goods_category where name = '手机数码'
-- 上一步的子查询充当条件
select name from tp_goods_category where parent_id = (
select id from tp_goods_category where name = '手机数码'
)
3. 查询Tpshop的订单信息
- 查询出Tpshop中当前用户的订单信息

-- 查询出Tpshop中当前用户的订单信息
-- 13800138006
-- 1. 找到登陆用户的user_id, 通过用户手机号过滤
select user_id from tp_users where mobile = '13800138006'
-- 2. 找订单,通过user_id过滤
select * from tp_order where user_id = (
select user_id from tp_users where mobile = '13800138006'
)
-- 3. 查询订单的order_id
select order_id from tp_order where user_id = (
select user_id from tp_users where mobile = '13800138006'
)
-- 4. 查商品信息,通过order_id找
select * from tp_order_goods where order_id in (
select order_id from tp_order where user_id = (
select user_id from tp_users where mobile = '13800138006'
)
)
4. 查询用户的购物车信息
- 查询出Tpshop当前用户中的购物车信息

-- 查询出Tpshop当前用户中的购物车信息
-- 13800138006
-- 1. 找到登陆用户的user_id, 通过用户手机号过滤
select user_id from tp_users where mobile = '13800138006'
select * from tp_cart where user_id = 8
select * from tp_cart where user_id = (
select user_id from tp_users where mobile = '13800138006'
)
3. 数据修改演练
1. 修改用户的昵称

- 通过SQL语句修改Tpshop当前用户的昵称为 Test001
select nickname, pay_points from tp_users where mobile = '13800138006'
-- 通过SQL语句修改Tpshop当前用户的昵称为 test001
-- 通过SQL语句将用户的积分值修改为 20000
update tp_users set nickname='test001', pay_points = 20000 where mobile = '13800138006'
2. 修改用户的积分

- 通过SQL语句将用户的积分值修改为20000
select nickname, pay_points from tp_users where mobile = '13800138006'
-- 通过SQL语句修改Tpshop当前用户的昵称为 test001
-- 通过SQL语句将用户的积分值修改为20000
update tp_users set nickname = 'test001', pay_points = 20000 where mobile = '13800138006'