Paozhu logo Paozhu Docs
Documentation
START

Quick start

Install dependencies, build, start the server and verify the first route.

1. Install dependencies

Paozhu needs a C++20 compiler, CMake, Asio, OpenSSL, Zlib and Brotli. SQLite and Redis are optional and controlled by build flags.

terminalbash
# macOS
brew install asio cmake openssl zlib brotli

# Ubuntu / Debian
sudo apt-get install cmake
sudo apt-get install -y brotli libbrotli-dev zlib1g-dev
sudo apt-get install openssl libssl-dev

# Rocky / AlmaLinux
sudo dnf -y upgrade
sudo dnf install gcc g++ cmake libasan
sudo dnf install brotli brotli-devel openssl openssl-devel

2. Get the source and trim the scaffold

The repository ships full examples and CMS controllers. mini_project.sh keeps only testhello.cpp and serverwatch.cpp, which is a clean starting point.

terminalbash
git clone https://github.com/hggq/paozhu.git myproject
cd myproject
sh mini_project.sh
# keep only testhello.cpp + serverwatch.cpp as a clean starting point

3. Build

CMake defaults to Debug when no build type is given. Use -DCMAKE_BUILD_TYPE=Release for production. The executable is written to bin/ in the project root.

terminalbash
unzip asio.zip
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j8
cd ..

# run from the project root
./bin/paozhu conf/server.conf

4. Know the layout

project treetext
paozhu/
├── bin/paozhu                 # built executable
├── conf/                      # server.conf / orm.conf / acme.conf / *.sql
├── controller/
│   ├── src/                   # business controllers, scanned for annotations
│   └── include/               # header stubs generated at configure time
├── models/                    # thin business model wrappers
├── orm/                       # generated field metadata + SQL operation layer
├── view/  viewsrc/            # templates and compiled views
├── www/default/               # static site root (wwwpath)
├── log/  temp/                # logs and temporary files
├── startup/                   # main_dev / main_daemon / main_docker
└── common/autocontrolmethod.hpp  # generated route table

5. Run and verify

Run from the project root. The argument can be conf/server.conf or the conf/ directory. Defaults are ports 80 and 443; if they are busy, change httpport / httpsport or bind a domain in hosts.

terminalbash
curl -I http://127.0.0.1/hello
curl -I http://127.0.0.1/plaintext
# If port 80 is busy:
lsof -i :80
sudo ss -tlnp | grep 80
# change conf/server.conf when the port is busy:
# httpport = 8080