The editor of Downcodes brings you a WeChat applet - Campus Little Love Letter background source code deployment tutorial. This is an open source confession wall project. You can choose to use the provided Docker deployment solution or build your own environment. This document will guide you in detail on how to independently deploy the Little Love Letter backend service and quickly build a love-filled confession platform. Whether you are a technical expert or a novice, you can easily get started!
WeChat applet - campus love letter background source code, fun confession wall, confession wall.
Little Love Letter is an open source project. You can use Ye Zi's backend, or you can build your own backend. This document is a tutorial for independently deploying Little Love Letter backend.
Project environment requirements
PHP 7.0 or above
MySQL 5.7
docker deployment method (recommended)
It only takes five minutes to deploy using docker, which is convenient and fast. You only need to configure a docker-compose file.
1. Deploy docker environment (ubuntu)
In order to simplify the installation process, Docker officially provides a set of convenient installation scripts. You can use this set of scripts to install on Ubuntu systems.
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
After executing this command, the script will automatically make all preparations and install Docker CE Edge in the system.
Start Docker CE
$ sudo systemctl enable docker
$ sudo systemctl start docker
Enter the following command to check whether docker is installed
$ docker -v
If the docker information is printed out, the installation is successful.
2. Install docker-compose
If your operating system is window or mac, it is already included when installing docker, and there is no need to install it separately. If your operating system is a linux system, you need to install it according to the following method.
Installation on Linux is also very simple. Just download the compiled binary file directly from the official GitHub Release.
For example, directly download the corresponding binary package on a Linux 64-bit system.
$ sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-uname -s-uname -m > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
If you encounter problems installing docker-compose, you can directly search for relevant information. There are many solutions.
3. Use docker-compose.yml to deploy the backend of Little Love Letter
1. Paste the docker-compose.yml in the background source code of Little Love Letter to the directory you need to deploy, and then configure the parameters required for the background project
docker-compose.yml file
2. Edit the docker-compose.yml file and fill in the project parameters
Just edit the parameters in the red box, fill in the corresponding parameters according to the prompts, and then save. The database name must be love_wall, and the database user name must be root.
3. Start the project and execute the command
docker-compose -up -d
The first startup will take a while because you need to pull the image for the first time, so be patient.
The project startup is completed and docker-compose will start
nginx
php-fpm
mysql
phpmyadmin.
Notice
The project can be accessed locally by accessing 127.0.0.1:8000
phpmyadmin is accessed through 127.0.0.1:8080, the host is db, and the love_wall.sql in the project directory can be imported into the database.
If you are in a local window or mac development environment, you can access it directly like this. If it is an online cloud host, you can use your IP + port to access it. The cloud host needs the firewall to open ports 8000 and 8080 to access it. You can open it directly in the browser locally. Just access it. If you want to access it through a domain name, you need to deploy nginx on the host machine to forward the request to 127.0.0.1:8000 and 127.0.0.1:8080 to access the project and phpmyadmin.
4. Stop the project and execute the following command to stop the project
docker-compose down
If you want to start the project again, just execute docker-compose up -d
Manual deployment method
1. Download the background source code
1.1 Directly download the background source code
Just click download to download the source code.
Don’t forget to click star in the upper right corner
Build Status
1.2 Use git to obtain source code
Enter the command in Git
git clone https://github.com/oubingbing/wechatAlliance.git
2. Install the PHP package management tool composer
Installation - Windows
Use the installer
This is the easiest way to install Composer on your machine.
Download and run Composer-Setup.exe, which will install the original Composer and set the system environment variables, so you can use the composer command directly in any directory.
Composer download address: https://getcomposer.org/Composer-Setup.exe
Just download and run it directly.
After the installation is complete, enter in the terminal
composer -v When you see the picture below, it means the installation is successful.
Build Status
3. Install PHP’s laravel framework
PHP's laravel framework is a very excellent PHP framework. If you are interested, you can learn it.
This is the website for Chinese documentation: https://laravelacademy.org/
After downloading the source code, you can enter the project root directory and use the cmd command line tool or other terminal tools. Data command:
composer install
Install laravel framework
Build Status
Just wait until it is installed.
After the installation is complete, enter
composer dump-autoload
4. Configuration items
Rename the .env.example file in the project root directory to a .env file
APP_NAME=Little Love Letter
APP_ENV=local (local during development, changed to prod during deployment)
APP_KEY=(laravel secret key)
APP_DEBUG=true (false during development, changed to true during deployment)
APPLOGLEVEL=debug
APP_LOG=daily
APP_URL=https://kucaroom.com
DB_CONNECTION=mysql
DB_HOST=(IP address of the host where the database is located)
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=
REDIS_PASSWORD=
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHERAPPID=
PUSHERAPPKEY=
PUSHERAPPSECRET=
API_PREFIX=api
JWT_SECRET=
QINIUACCESS_KEY=
QINIUSECRET_KEY=
BUCKET_NAME=
QINIUDOMAIN=
SENDCLOUDAPI_USER=
SENDCLOUDAPP_KEY=
YUNPIANSINGLE_URL=
YUNPIANMULTI=
YUNPIANKEY=
ALI_ID=
ALI_SECRET=
ALI_URL=
1. Generate app_key
Terminal input: php artisan key:generate
Then a message will be displayed. Just copy the string in [] square brackets and paste it into APP_KEY of .env.
Application key [base64:3ZYAJ6R5fzNcQpc1kfEuhMQJZU06HUXt93BS92UK8Pc=] set successfully.
2. APP_URL=https://kucaroom.com, the domain name of the application, for sending an email activation link, just fill in your project domain name
3. Database, enter the information corresponding to your data
DB_CONNECTION=mysql
DB_HOST=(IP address of the host where the database is located)
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
4. Redis cache, configure your Redis account password
REDIS_HOST=
REDIS_PASSWORD=
REDIS_PORT=6379
5. Generate jwt key and use dingo api
Enter the command: php artisan jwt:secret
The result is as follows, copy the string in brackets to JWT_SECRET=
jwt-auth secret [pV7G5egB2TfcLwpc3J8xEqiudof5SxyM] set successfully.
6. Qiniu configuration
Register an account in Qiniu, get Qiniu's accesskey, secretkey and the name of the storage bucket and fill it in below. It is used for uploading images of small programs. The best storage area is South China, which is Z2.
QINIUACCESS_KEY=
QINIUSECRET_KEY=
BUCKET_NAME=
QINIUDOMAIN= //Your Qiniu domain name
7. sendcloud email configuration
Register a sendcloud account and configure the following information
SENDCLOUDAPI_USER=
SENDCLOUDAPP_KEY=
8. Configure cloud picture SMS
For sending text messages
YUNPIANSINGLE_URL=
YUNPIANMULTI=
YUNPIANKEY=
9. Configure Alibaba Cloud developer information
ALI_ID=
ALI_SECRET=
//For example: viapiutils.cn-shanghai.aliyuncs.com
ALI_ENDPOINT=
ALIENDPOINTID
Alibaba face recognition address
https://data.aliyun.com/product/face?spm=5176.10609282.1146454.885.21d538010MzGRj#face-verify
The text message of the SMS verification code is in
Modify sendMessageCode($phone) in wechatAllianceappHttpServiceYunPianService.php.
The SMS text message of the confession post is in
Store() modification in wechatAllianceappHttpControllersWechatPostController.php
You are required to register a text message template related to Yunpian and fill in the information in the template according to your needs.
5. Generate database tables
Run in the project root directory
php artisan migrate
To migrate data tables, MySQL must be 5.7 or above, otherwise an error will be reported.
The data table files are in this directory: wechatAlliancedatabasemigrations
6. Run the project
Run in the project root directory
php artian serve
The project can be started by typing in the browser
http://127.0.0.1:8000
You can access the project
After officially deploying to Linux, you only need to point the request for port 80 or 443 to the public directory of the project.
If you find it helpful, you can tip the author, thank you.
I hope this tutorial can help you successfully deploy the Little Love Letter backend! If you have any questions, please feel free to leave a message. I wish you success in expressing your love!