This article is about documenting the Coupons project installation process in a Linux environment

Coupons is a completely open source Taobao customer project from front end to back end. Currently, the project can be packaged into App, wechat applets, QQ applets and Web sites. Theoretically other applets are supported and may need tweaking

Github Address: Project Address: github.com/silently952…

Results the preview


First, operating environment

Java

  1. Use yum to search for installation packagesyum search openjdk

  2. Here we select the Java8 development environment and run the following command

Yum -y install Java - 1.8.0 comes with - its. X86_64Copy the code
  1. Verify that the installation is successful
java -version
Copy the code

Enter the following information to indicate that the installation is successful

Openjdk Runtime Environment (build 1.8.0_302-B08) OpenJDK 64-bit Server VM (build 25.302 - b08, mixed mode)Copy the code

2. Register a third-party account

1. Register a taobao account

All of the product data used in the MallCoupons backend project is provided by the Taw API;

First, you need to register your account

Enter dataoke open platform to create an application, add all API interfaces for the application in one click

2. Open MobTech free SMS service (optional, you need to pack the app)

MallCoupons from the App is signed in with a mobile phone number and a verification code. MobTech offers free SMS verification codes.

Set up a MobTech account

Go to the developer platform and create an app

3. Register QQ mini program (optional, according to personal needs)

4. Sign up for wechat mini program (optional, based on personal needs)


Download the source code and decompress it

wget https://codeload.github.com/silently9527/coupons/zip/refs/heads/master
unzip coupons-master.zip
Copy the code

Create and initialize the database

  1. Enter the password to log in to the MySQL database
mysql --port=3309 -uroot -p
Copy the code
  1. Create database mall-Coupons
create database mall-coupons default character set utf8mb4 collate utf8mb4_unicode_ci;
Copy the code
  1. Run the following command to initialize the database
use mall-coupons;
source /Users/xxx/Downloads/coupons-master/doc/scheme.sql
Copy the code

Replace the file path after the source command with your own path;


Fifth, back-end project packaging

  1. To extract the project of coupons – master/server/SRC/main/resources directory
cd coupons-master/server/src/main/resources
Copy the code
  1. Vim edits filesapplication-prod.propertiesTo modify the required parameters in the file
Token, token, token, token, token, token, token, token, token, token, token, token, token, token, token, token, token, token, token Spring.social.qi.app-secret = # Fill in the previous registration wechat small program appId, appSecret spring.social.wechat. App-id = spring.social.wechat. App-secret = # configuration MySQL database address spring. The datasource. Url = JDBC: MySQL: / / localhost: 3306 / mall - coupons? autoReconnect=true&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai Spring. The datasource. The username = root spring. The datasource. The password = # XXX configuration Redis server address spring. Redis. Host = spring. Redis. Password = Port = # mob SMS service appKey = MOBS. Service. Appkey =Copy the code
  1. Packaging Java projects
mvn clean package -DskipTests
Copy the code

The package is complete when Build Success appears

After the package is complete, the target directory will be generated from the current directory. CD target goes to the directory and check whether there is a generate file mall-coupons -server-0.0.1-snapshot.jar

  1. Is up and runningMall - coupons - server - 0.0.1 - the SNAPSHOT. The jar
Java-djava.security.egd =file:/dev/./ urandom-jar mall-coupons-server-0.0.1 -snapshot.jar -- spry.profiles. Active =prod >  ./mall-coupons-server.log &Copy the code

Nginx configuration

  1. Go to the directory/etc/nginx/conf.dTo create a configuration filecoupon.conf
cd /etc/nginx/conf.d
touch coupon.conf
Copy the code
  1. Editing a Configuration Filecoupon.conf, enter the following information:
upstream coupons-services { server localhost:9090 weight=10; } server { listen 80; Server_name Your domain name; include /etc/nginx/default.d/*.conf; location / { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-a uth-token'; if ($request_method = 'OPTIONS') { return 204; } proxy_pass http://coupons-services/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10000m; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }Copy the code
  1. Restart the nginx
systemctl restart nginx
Copy the code

Seven, front-end project packaging

  1. Front-end project source directory coupons – master/client import into HBuilder front-end code, how to use HBuilder import project, packaging can refer to the official documentation uniapp. Dcloud. IO/quickstart -…

  2. Change the TEMPLATE ID for sending SMS messages (required only when app packaging is required). Configure the SMS template ID in line 92 of pages/public/login.vue, where the template ID needs to be applied on the SMS platform Mob

  1. Purchase mob integration plug-ins from uniapp’s plug-in center; MobTech SMS native plugin ext.dcloud.net.cn/plugin?id=2…

  2. Then configure appKey in HBuilder

  1. Configure the background API request address, editclient/config.jsEnter the domain name address of your server
module.exports = {
    // APIHOST: "http://localhost:9090"
}
Copy the code

Coupons project related documents have been updated to blog: silently9527. Cn /