Hello! [Log in]
CollEntRes C++ library for high performance websites

Simple Website Installation


It is assumed that you have installed CollEntRes C++ library on your clean Ubuntu 16.04 system. If not, go to Install CollEntRes page in order to find out how to do this.

Please open Terminal and install some packages by executing the following commands:

# apt-get update
# apt-get install build-essential

C++ IDE Installation

Any modern C++ IDE software can be used for C++ web development, but we will install and use JetBrains CLion that is an awesome cross-platform C++ IDE. You can download it from official website (free 30-day trial). For this tutorial, CLion 2017.3 was the actual version.

Simple Website Project Installation

Download the archive file with Simple Website project files from How To Use page and extract the simple_website folder from there to ~/CLionProjects folder. So the project's path will be ~/CLionProjects/simple_website

Allow a web server to upload images by executing the following commands in Terminal:

# chmod 777 ~/CLionProjects/simple_website/www/uploads/avatar
# chmod 777 ~/CLionProjects/simple_website/www/uploads/image

Open Clion, then click File -> Open... in order to open a project. In the dialog window, select simple_website folder that has project's files and click OK. After this, CLion will initialize a new CLion project with existing project files and open it.

Go to File -> Settings -> Build, Execution, Deployment -> CMake. Below Profiles, you should see Debug item. Please click + in order to create Release configuration. Enter -j 4 in Build options for Debug and Release, if your processor has four threads (cores). After that, click OK.

Go to File -> Settings -> Editor -> File Types. Select HTML under Recognized File Types, add *.chtml file extension under Registered Patterns and click OK.

Open simple_website|Debug dropdown and select Release configuration. Then go to Run -> Edit Configurations..., select simple_website as executable and set working directory to /home/user/CLionProjects/simple_website (it is required because it allows a simple_website executable to find config.json file and read website configuration parameters from there), and click OK.

You can build simple_website executable now. In order to do this, click Run -> Build. You will find simple_website executable file in ~/CLionProjects/simple_website/cmake-build-release folder after successful build.

Zapcc C++ Compiler Installation

This step is optional, but it is recommended to perform it now or later.

Zapcc C++ compiler is used to make the recompilation of a large number of project files take much less execution time. In most cases, you don't need to recompile a lot of project files, but there are cases, when you need to modify some C++ header files, which are included by the most of project files. So, in these cases, Zapcc C++ will be very helpful.

Download the archive file with Zapcc C++ compiler's files from official website to your user home folder. Open Terminal and execute the following commands:

# cp ~/zapcc-20170802-175507.7z /opt/zapcc-20170802-175507.7z
# apt-get install p7zip-full
# cd /opt
# 7z x zapcc-20170802-175507.7z
# rm zapcc-20170802-175507.7z

Open CMakeLists.txt file (from project root folder) in CLion and add the following two lines

set(CMAKE_C_COMPILER /opt/zapcc-20170802-175507/bin/zapcc)
set(CMAKE_CXX_COMPILER /opt/zapcc-20170802-175507/bin/zapcc++)

after project(simple_website) line and remove (or comment out) the following lines:

# We use ccache in order to speed up compilation process.
find_program(CCACHE_FOUND ccache)

That's all. CLion will use Zapcc C++ compiler now if you click Run -> Build. Keep in mind that Zapcc C++ consumes a lot of RAM and it is recommended to use this compiler if you have at least 6 GB.

Configuring Database

Open Terminal and execute the following command in order to install MySQL server:

# apt-get mysql-server

For this tutorial, MySQL 5.7 was the actual version.

Extract simple_website DB.sql file from simple-website-X.X.X.zip archive and execute SQL statements from there using your favourite MySQL client (it can be mysql command line tool, HeidiSQL, MySQL Workbench, etc). It will create simple_website database that will be used by simple_website executable.

Simple Website uses different timezones in order to present time. timezonedb database contains information about each timezone (timezone name, GMT offset, etc). So you also need to install this database. Go to official website, download timezonedb.sql.zip archive file and extract timezonedb.sql file. Open your MySQL client, connect to MySQL server, create empty timezonedb database and make it be default (USE timezonedb;). Then execute statements from timezonedb.sql file.

So your MySQL server have two databases, which will be used by simbple_website executable: simple_website and timezonedb.

Google ReCAPTCHA Registration

Simple Website uses Google ReCAPTCHA to protect itself from bots. Please register ReCAPTCHA V2 for simple-website.local.com domain, get the site key and the secret (api key) and store them to ReCAPTCHA section of config.json file.

Running Simple Website Executable

Open CLion and open simple_website project. Open config.json file and replace YOUR_DB_USER and YOUR_DB_PASSWORD with your DB user and password. After that, click Run -> Run... in order to build and run simple_website executable.

If everything is fine, then CLion will output the following lines:

New connection opened
Occupied/opened connections: 0/1
Connection to DB has been occupied.
sql: SELECT * FROM `url_alias` ua
sql: SELECT * FROM `lang` l
sql: SELECT * FROM `timezone` tz
sql: SELECT `value` FROM `setting` s WHERE `type` = 'js_css_v' LIMIT 1
Connection to DB has been released.

If you see Host localhost has multiple addresses... error, then open config.json file, replace localhost:8083 with, save the file and run simple_website again.

You can also run simple_website executable without CLion. In order to do this, open Terminal and execute the following commands:

$ cd ~/CLionProjects/simple_website
$ ~/CLionProjects/simple_website/cmake-build-release/simple_website

Note that simple_website is configured to use 8083 port for incoming connections from the web server with FastCGI support. So this port should not be occupied by some other program. You can also change the port to some other port or UNIX socket path in config.json file (socketPath property).


So you have installed Simple Website project files on your computer. On the next step, you will find out how to configure Apache Web Server so it can communicate via FastCGI and proxy client requests for dynamic pages to CollEntRes C++ library.