2. Environment configuration, project operation - TinyWebServer

Environment configuration, project running - TinyWebServer

I. Introduction

The basic structure of this project has been introduced in the previous issue. If you don’t know, you can click on the homepage to find it.
before writing code. The general step is to download other people's code first and run it. First, on the one hand, see whether the final effect is what you want, and second, on the other hand, grasp the general outline of the project.
TinyWebServer —— GitHub

2. Environment configuration

  • Linux (the author uses Ubuntu 22.04 LST)
  • Database (Mysql used by the author)
  • Create basic table

Ⅰ、Linux

I won’t walk you through the installation here. On the one hand, there are many online tutorials. Secondly, I guess they have all started writing projects, and they should also be able to play Linux.

Ⅱ. Database

1. Database installation
# 安装mysql
sudo apt upgrade && sudo apt install mysql-server mysql-client libmysqlclient-dev
# 进入mysql
sudo mysql -u root
# 创建用户——这里根据自己所需配置
create user 'starry'@'%' identified by 'root';
# 给新用户符全部权限
grant all on *.* to 'starry'@'%';

# 退出mysql
exit

# 设置mysql远程连接
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 改成
bind-address = 0.0.0.0
# 重启mysql服务
sudo service mysql restart
1. Creation of table
# 进入mysql
sudo mysql -u root
# 创建数据库qgydb
create database qgydb;
# 使用数据库qgydb
use qgydb;
# 创建user表
USE yourdb;
CREATE TABLE user(
    username char(50) NULL,
    passwd char(50) NULL
)ENGINE=InnoDB;

# 添加数据
INSERT INTO user(username, passwd) VALUES('name', 'passwd');

3. Download the code, compile and run

Ⅰ. Download to local

1. Click here to copy the download link

Insert image description here

2. Use git cloned local
# 没有git的使用下面命令(有git忽略此步骤)
sudo apt install git -y
# 执行下面的命令吧项目克隆到本地
git clone https://github.com/qinguoyi/TinyWebServer.git
3. Enter the project, modify the main.cpp file configuration, and execute make
 cd TinyWebServer
 vi main.cpp
 make

Insert image description here

4. Run the executable file and access the project
# 运行
./server  
# 打开浏览器,访问
http://127.0.0.1:9006/

Insert image description here

3. Preview of next issue

Analyze the writing and analysis of lock

4. Finally

Seeking Like!

Guess you like

Origin blog.csdn.net/Ten_years_star/article/details/132784019