# Ego
**Repository Path**: xxchk123/Ego
## Basic Information
- **Project Name**: Ego
- **Description**: Ego是一款电商类小程序,结合后台业务实现特色商品线上购物的微信小程序移动端应用项目。
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2024-07-07
- **Last Updated**: 2025-05-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Ego
#### 介绍
Ego是一款B/C电商类小程序,结合后台业务实现特色商品线上购物的微信小程序移动端应用项目。
项目符合C/S架构,前后端代码分离。
#### 软件架构
软件架构说明:
前端采用微信小程序(WXML+WXSS+JavaScript)
后端采用LAMP架构(Linux+Apache+MySQL+PHP)、
#### 使用说明
1. Linux中部署后端代码
2. 前端代码使用微信开发者工具部署
3. 使用Postman + newman + jenkins 实现持续集成、发送邮件测试报告
4. 使用Python + requests + unittest + HTMLTestRunner + Jenkins 实现持续集成、发送邮件测试报告
#### 基本功能模块
- 主页模块:以商品展示为主,主要是热门商品、主题商品、新品展示
- 分类模块:以不同类别展示商品,按不同属性归类,以及归类后的展示
- 购物车模块:意向商品的添加、修改、统计,为下单做准备
- 我的模块:个人中心信息,显示有关人地址、订单等相关信息
#### 业务流程
流程一:进入小程序-是否授权-授权失败
流程二:进入小程序-是否授权-授权成功-登录小程序-商品浏览-退出结束
流程三:进入小程序-是否授权-授权成功-登录小程序-商品浏览-添加购物车-下单-库存不足-下单失败
流程四:进入小程序-是否授权-授权成功-登录小程序-商品浏览-添加购物车-下单-库存充足-下单成功-订单支付-支付失败-待付款
流程五:进入小程序-是否授权-授权成功-登录小程序-商品浏览-添加购物车-下单-库存充足-下单成功-订单支付-支付成功-已支付-已发货-结束
#### 测试工具
Nxshell、Navicat、Fiddler、微信开发者工具、Linux
#### 安装教程
- 注册微信小程序,获取APPID和APPSecret
- 后端在Linux上部署
- 先查看是否安装wget——>rpm -qa | grep "wget"
- 一键部署LAMP
- ```shell
wget http://soft.lnmp.com/lnmp/lnmp2.1.tar.gz -O lnmp2.1.tar.gz && tar zxf lnmp2.1.tar.gz && cd lnmp2.1 && LNMP_Auto="y" DBSelect="5" Bin="y" DB_Root_Password="123456" InstallInnodb="y" PHPSelect="0" SelectMalloc="1" ApacheSelect="0" ServerAdmin="zhanghuaidongwork.com" ./install.sh lamp
```
- 安装Apache
```
ping mirrors.aliyun.com
#备份官方的原yum源的配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载Centos-7.repo文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 清除yum缓存
yum clean all
# 缓存阿里云源
yum makecache
# 测试阿里云源
yum list
#安装Apache服务器
yum install httpd
#查看Apache当前端口
netstat -antlupe | grep "httpd"
#启动Apache
systemctl start httpd
systemctl enable httpd
#查看Apache启动状态
systemctl status httpd
```
- 安装MySQL
```
#进入安装包目录
cd /usr/local/
#wget下载
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.30-el7-x86_64.tar
#拆分tar包
tar -xvf mysql-8.0.30-el7-x86_64.tar
#解压安装包
tar -zxvf mysql-8.0.30-el7-x86_64.tar.gz
#将解压后的文件夹重命名为mysql
mv mysql-8.0.30-el7-x86_64/ mysql
#创建存储数据文件
mkdir mysql/data
#设置用户组并赋权
groupadd mysql
#创建用户 -r:创建系统用户 -g:指定用户组
useradd -r -g mysql mysql
#更改属主和数组
chown -R mysql:mysql /usr/local/mysql/
#更改权限
chmod -R 755 /usr/local/mysql/
#初始化MySQL
cd /usr/local/mysql/bin/
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
#配置参数文件
vi /etc/my.cnf
###my.cnf
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect = 'SET NAMES utf8mb4'
port = 3306
socket = /usr/local/mysql/data/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
datadir = /usr/local/mysql/data
#lower_case_table_names=1
#如果要设置lower_case_table_names可以在初始化里面设置 ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --lower_case_table_names=1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
###
#配置后修改 /etc/my.cnf 的权限为777
chmod 777 /etc/my.cnf
#启动MySQL
/usr/local/mysql/support-files/mysql.server start
#设置软连接,并重启MySQL
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/mysql.sock /var/mysql.sock
service mysql restart
#登录并更改密码
mysql -uroot -p
alter user 'root'@'localhost' identified by '123456';
#开放远程连接
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges; //刷新权限
#设置开机自启动(可选)
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#赋予可执行权限
chmod +x /etc/init.d/mysqld
#添加服务
chkconfig --add mysqld
#显示服务列表
chkconfig --list
chkconfig --level 345 mysqld on
#重启系统
reboot
#查看mysql是否开机自启动
ps -ef | grep 'mysql'
```
- 安装PHP
```
#安装EPEL仓库
yum install epel-release
#安装Remi仓库:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
#启用Remi PHP 5.6仓库:
yum-config-manager --enable remi-php56
#安装PHP 5.6:
yum install php php-common php-mysql php-fpm
#启动PHP-FPM服务
systemctl start php-fpm
#设置开机自启动
systemctl enable php-fpm
#查看PHP运行状态
systemctl status php-fpm
```
- 查看是否启动成功
```
systemctl status httpd #apache
systemctl status mysqld #mysql
systemctl status php-fpm #php
```
- 修改配置文件
```
#配置文件路径
vim /etc/httpd/conf/httpd.conf
修改监听端口为13140
Listen 13140 #默认监听80端口
#配置虚拟域名
ServerName www.ego.com
DocumentRoot "/var/www/html" #运行代码存放位置
LoadModule rewrite_module modules/mod_rewrite.so
AllowOverride All
Require all granted
#将13140端口加入SE Linux
semanage port -a -t http_port_t -p tcp 13140
#重启Apache
systemctl restart httpd
#查看Apache启动状态
systemctl status httpd
#浏览器访问www.ego.com:13140,测试配置
#创建httpd-vhosts.conf配置文件执行后端代码访问public目录
vim /etc/httpd/conf.d/httpd-vhosts.conf
#httpd-vhosts.conf
#/etc/httpd/conf.d/httpd-vhosts.conf
DocumentRoot "/var/www/html/"
ServerName localhost
DocumentRoot "/var/www/html/ego_server/public"
ServerName www.ego.com
#重启Apache
systemctl restart httpd
```
- Xshell 上传 ego_server 代码到路径目录 /var/www/html/ 下
- Navicat创建连接,配置Ego数据库,运行ego.sql文件,创建数据库数据
- 修改代码配置
```
#修改数据库连接文件
vim /var/www/html/ego_server/application/database.php
vim /var/www/html/ego_server/public/cms/js/common.js
g_restUrl:'http://www.ego.com:13140/api/v1/', #修改g_restUrl
#修改自己的小程序APPID和密钥
vi /var/www/html/ego_server/application/extra/wx.php
#vim /var/www/html/ego_server/application/extra/setting.php
'img_prefix'=>'http://www.ego.com:13140/images/', #修改图片域名
#重启Apache 和 MySQL数据库
systemctl restart httpd
systemctl restart mysqld
#查看运行状态
systemctl status httpd
systemctl status mysqld
```
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)