- 首页
- 列表
- 详情
- 购物车
- spring-mvc
- MySQL
- Vue.js
- Vue Router
- Vuex
- axios
安装时用户名:xjtu
密码:xjtuxjtu
用户名和密码请保持一致。
-
下载CentOS镜像
http://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1708.iso
-
在虚拟机中安装CentOS。
-
添加xjtu用户到sudoers文件 (添加xjtu用户到sudo用户组)
1. 切换到root用户 su 2. 编辑/etc/sudoers文件 vi /etc/sudoers 3. 在93行添加一下内容(set nu显示行号) xjtu ALL=(ALL) ALL 4. 保存退出 5. 退出root用户 exit
参考: https://jingyan.baidu.com/article/9f63fb91a9a7a3c8400f0ecb.html
-
安装成功后配置阿里云Linux安装软件镜像源(为了提高安装软件速度)
1. 备份你的原镜像文件 sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bac 2. 下载新的CentOS-Base.repo文件并保存到/etc/yum.repos.d/下 sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 3. 运行yum makecache生成缓存 sudo yum makecache
命令中的-O 是大写的O,不是数字0。
-
安装SSH(远程登录)和wget
sudo yum -y install openssh-server sudo yum install -y wget
-
配置网络(确保能上网)
-
下载安装
sudo yum -y install git
-
下载项目代码
sudo mkdir /developer sudo chown -R xjtu.xjtu /developer mkdir /developer/git-repository cd /developer/git-repository git clone https://github.com/AotY/Vue-Spring-demo
sudo cp /developer/git-repository/Vue-Spring-demo/config/selinux/config /etc/sysconfig/selinux
su
setenforce 0
exit
-
关闭防火墙
sudo systemctl stop firewalld sudo systemctl mask firewalld
-
安装iptables
sudo yum install -y iptables-services sudo systemctl enable iptables
-
配置iptables
sudo cp /developer/git-repository/Vue-Spring-demo/config/iptables /etc/sysconfig/iptables
-
启动iptables
sudo service iptables save sudo systemctl start iptables
sudo cp /developer/git-repository/Vue-Spring-demo/config/hosts /etc/hosts
-
下载
cd ~ wget http://learning.happymmall.com/jdk/jdk-7u80-linux-x64.rpm
-
安装 (安装默认位置在/usr/java/)
sudo rpm -Uvh jdk-7u80-linux-x64.rpm
-
配置profile
sudo cp /developer/git-repository/Vue-Spring-demo/config/profile /etc/profile
-
下载安装
cd ~ # wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz (这个链接失效了,请使用下面的一条命令(地址)) wget https://oiw0skz2u.qnssl.com/o_1bv1pv3nh1aqv1b8q1p5s14411fu1h.gz\?attname\=apache-tomcat-8.5.20.tar.gz\&e\=1510819228\&token\=RhbJn4QNVTV6pnuObXel6iSMlhnWHKR9b_tp6Xeu:pbl1dUyUApZhRO8Xny1W04RhHlI\= -O apache-tomcat-8.5.20.tar.gz tar -xvf apache-tomcat-8.5.20.tar.gz mv apache-tomcat-8.5.20 /developer
-
配置
cp /developer/git-repository/Vue-Spring-demo/config/tomcat/server.xml /developer/apache-tomcat-8.5.20/conf/server.xml cp /developer/git-repository/Vue-Spring-demo/config/tomcat/setenv.sh /developer/apache-tomcat-8.5.20/bin/setenv.sh
-
启动
/developer/apache-tomcat-8.5.20/bin/startup.sh
-
安装
wget http://learning.happymmall.com/maven/apache-maven-3.0.5-bin.tar.gz tar -xvf apache-maven-3.0.5-bin.tar.gz mv apache-maven-3.0.5 /developer
-
配置
cp /developer/git-repository/Vue-Spring-demo/config/maven/settings.xml /developer/apache-maven-3.0.5/conf/settings.xml
-
安装vsftpd
sudo yum install -y vsftpd
-
配置vsftpd
1. 创建ftp用户(只能登录ftp,不能登录系统) sudo mkdir /ftpfile # ftp文件夹 sudo useradd ftpuser -d /ftpfile -s /sbin/nologin #创建用户,没有登陆系统权限 sudo passwd ftpuser #设置ftpuser密码(这里设置为12345678) sudo chown -R ftpuser.ftpuser /ftpfile #赋予ftpuser访问ftpfile文件夹权限 2. 配置vsftpd.conf sudo cp /developer/git-repository/Vue-Spring-demo/config/vsftp/vsftpd.conf /etc/vsftpd/vsftpd.conf sudo cp /developer/git-repository/Vue-Spring-demo/config/vsftp/chroot_list /etc/vsftpd/chroot_list
-
启动vsftpd
sudo service vsftpd start
sudo chkconfig vsftpd on # 设置开机自启
vsftpd相关命令:
sudo service vsftpd start
sudo service vsftpd stop
sudo service vsftpd restart
-
导入项目需要使用的图片
sudo yum install -y unzip sudo cp /developer/git-repository/Vue-Spring-demo/ftpfile/image.zip /ftpfile/ cd /ftpfile sudo unzip image.zip sudo chown -R ftpuser.ftpuser /ftpfile #(因为image.zip拥有者是root)
-
下载安装
cd ~ wget http://nginx.org/download/nginx-1.12.1.tar.gz tar -xvf nginx-1.12.1.tar.gz cd nginx-1.12.1 sudo yum install -y gcc gcc-c++ make zlib-devel pcre-devel openssl-devel ./configure --prefix=/usr/local/nginx make sudo make install
-
配置
sudo cp /developer/git-repository/Vue-Spring-demo/config/nginx/nginx.conf /usr/local/nginx/conf sudo mkdir /usr/local/nginx/conf/vhost sudo cp /developer/git-repository/Vue-Spring-demo/config/nginx/vhost/www.vuespringdemo.com.conf /usr/local/nginx/conf/vhost/ sudo cp /developer/git-repository/Vue-Spring-demo/config/nginx/vhost/backend.vuespringdemo.com.conf /usr/local/nginx/conf/vhost/ sudo cp /developer/git-repository/Vue-Spring-demo/config/nginx/vhost/image.vuespringdemo.com.conf /usr/local/nginx/conf/vhost/
-
启动nginx
cd /usr/local/nginx/sbin sudo ./nginx
-
安装
1. 查看系统是否安装了MySQL rpm -qa | grep mysql 2. 如果安装了使用下面命令卸载 sudo rpm -qa | grep mysql yum remove mysql mysql-client mysql-server mysql-common mysql-devel sudo mv /var/lib/mysql /var/lib/mysql_old_backup sudo rm -rf /var/lib/mysql/ sudo rm -rf /etc/my.cnf
-
安装
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm sudo yum update sudo yum install mysql-server
-
启动
sudo systemctl enable mysqld sudo systemctl start mysqld
-
登录(第一次登录不用密码)
mysql -uroot -p
-
修改root密码
1. 查看用户 select user, host, password from mysql.user; 2. 设置密码 set password for root@localhost=password('xjtuxjtu'); set password for root@xjtu=password('xjtuxjtu'); set password for [email protected]=password('xjtuxjtu');
-
删除匿名用户
delete from mysql.user where user=''; 刷新权限 flush privileges;
-
新增用户
insert into mysql.user(host, user, password, ssl_cipher, x509_issuer, x509_subject) values ("localhost", "xjtu", password("xjtuxjtu"), "", "", ""); flush privileges;
-
创建数据库
CREATE DATABASE vue_spring_demo DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; use vue_spring_demo;
-
赋予用户权限
1. 本地权限 grant all privileges on vue_spring_demo.* to xjtu@localhost identified by 'xjtuxjtu'; 2. 远程权限 grant all privileges on vue_spring_demo.* to xjtu@'%' identified by 'xjtuxjtu'; 3.刷新权限 flush privileges;
-
导入数据库
exit;
mysql -u xjtu -p vue_spring_demo < /developer/git-repository/Vue-Spring-demo/backend/vue_spring_demo.sql
::1
is the IPv6 address for localhost.
-
下载安装nodejs
cd ~ wget https://nodejs.org/dist/v6.11.3/node-v6.11.3-linux-x64.tar.xz sudo mkdir /usr/local/nodejs sudo tar -xJvf node-v6.11.3-linux-x64.tar.xz -C /usr/local/nodejs sudo mv /usr/local/nodejs/node-v6.11.3-linux-x64/ /usr/local/nodejs/node-v6.11.3
-
使环境变量(之前已经配置)
source /etc/profile
-
验证
node -v npm version
-
安装cnpm(为了提高安装依赖包的速度)
npm install -g cnpm --registry=https://registry.npm.taobao.org
在本机(不是虚拟机)hosts文件中添加以下几行记录。
注意的是,需要将前面的IP换为自己虚拟机中的centOS的IP。
192.168.246.204(替换为自己的虚拟机ip) image.vuespringdemo.com
192.168.246.204(替换为自己的虚拟机ip) backend.vuespringdemo.com
192.168.246.204(替换为自己的虚拟机ip) www.vuespringdemo.com
- 进入项目目录
cd /developer/git-repository/Vue-Spring-demo
- 编译部署
sh ./deploy.sh
-
访问测试
在本机打开浏览器,地址栏输入:
www.vuespringdemo.com
如果能够看到页面主页则说明配置成功。
-
接口
http://backend.vuespringdemo.com/user/login.do
-
请求方式
POST
-
参数(例子)
username=admin password=1234
-
返回值
{ "status": 0, "data":{ "id": 26, "username": "admin", "password": "", "email": "[email protected]", "phone": "13800138000", "question": "问题", "answer": "答案", "role": 1, "createTime": null, "updateTime": null } }
-
接口
http://backend.vuespringdemo.com/user/logout.do
-
请求方式
POST
-
参数
无
-
返回值
{ "status": 0, "msg": "SUCCESS" }
-
接口
http://backend.vuespringdemo.com/user/register.do
-
请求方式
POST
-
参数(例子)
username=test password=1234 [email protected]
-
返回值
{ "status": 0, "msg": "注册成功" }
-
接口
http://backend.vuespringdemo.com/user/get_user_info.do
-
请求方式
GET
-
参数
无
-
返回值
{ "status": 0, "data":{ "id": 26, "username": "admin", "password": "", "email": "[email protected]", "phone": "13800138000", "question": "问题", "answer": "答案", "role": 1, "createTime": null, "updateTime": null } }
-
接口
http://backend.vuespringdemo.com/recommend/carousel.do
-
请求方式
GET
-
参数
无
-
返回值
{ "status": 0, "data":{ "imageHost": "http://image.vuespringdemo.com/", "carousels":[ {"id": 32, "productId": 27, "name": "Apple iPhone 8 (A1863) 64GB 深空灰色 移动联通电信4G手机", "image": "carousel-iPhone8.jpg",…}, {"id": 33, "productId": 28, "name": "锤子 坚果Pro 128GB 细红线特别版 全网通 移动联通电信4G手机 双卡双待", "image": "carousel-smartian-u2.jpg",…} ] } }
-
接口
http://backend.vuespringdemo.com/recommend/keyword.do
-
请求方式
GET
-
参数
无
-
返回值
{ "status": 0, "data":[ "手机", "锤子" ] }
-
接口
http://backend.vuespringdemo.com/product/list.do?keyword=手机&categoryId=0&orderBy=price_desc&pageSize=10&pageNum=1
-
请求方式
GET
-
参数
keyword=手机 (可选) categoryId=0(可选) orderBy=price_desc(可选) pageSize=10(可选) pageNum=1 (可选)
-
返回值
{ "status": 0, "data":{ "pageNum": 1, "pageSize": 1, "size": 1, "orderBy": "price desc", "startRow": 1, "endRow": 1, "total": 3, "pages": 3, "list":[ {"id": 27, "categoryId": 100012, "name": "Apple iPhone 8 Plus (A1864) 256GB 金色 移动联通电信4G手机", "subtitle": "【iPhone新品上市】新一代iPhone,让智能看起来更不一样",…} ], "firstPage": 1, "prePage": 0, "nextPage": 2, "lastPage": 3, "isFirstPage": true, "isLastPage": false, "hasPreviousPage": false, "hasNextPage": true, "navigatePages": 8, "navigatepageNums":[ 1, 2, 3 ] } }
-
接口
http://backend.vuespringdemo.com/product/detail.do?productId=26
-
请求方式
GET
-
参数
productId=26
-
返回值
{ "status": 0, "data":{ "id": 26, "categoryId": 100012, "name": "Apple iPhone 8 (A1863) 64GB 深空灰色 移动联通电信4G手机", "subtitle": "【iPhone新品上市】新一代iPhone,让智能看起来更不一样", "mainImage": "iphone8.png", "subImages": "iphone2.png", "detail": "iphone-detail.jpg", "price": 5888, "stock": 9991, "rate": 4.7, "status": 1, "createTime": "2017-09-23 15:42:52", "updateTime": "2017-09-23 15:42:55", "imageHost": "http://image.vuespringdemo.com/", "parentCategoryId": 0 } }
-
接口
http://backend.vuespringdemo.com/cart/add.do
-
请求方式
POST
-
参数
productId=26 quantity=2
-
返回值
{ "status": 0, "msg": "SUCCESS" }
-
接口
http://backend.vuespringdemo.com/cart/list.do
-
请求方式
GET
-
参数
无
-
返回值
-
接口
http://backend.vuespringdemo.com/order/create.do
-
请求方式
POST
-
参数
shippingId=30
-
返回值
{ "status": 0, "data":{ "orderNo": 1506955845058, "payment": 69414, "paymentType": 1, "paymentTypeDesc": "在线支付", "postage": 0, "status": 10, "statusDesc": "未付款", "paymentTime": "", "sendTime": "", "endTime": "", "closeTime": "", "createTime": "", "orderItemVoList":[ {"orderNo": 1506955845058, "productId": 26, "productName": null, "productImage": "iphone8.png",…}, {"orderNo": 1506955845058, "productId": 28, "productName": null, "productImage": "smartian-u2.png",…} ], "imageHost": "http://image.vuespringdemo.com/", "shippingId": 30, "receiverName": "无法长大", "shippingVo":{"id": 30, "receiverName": "无法长大", "receiverPhone": "18764397221", "receiverMobile": "18764397221",…} } }