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

Configure Web Server


It is assumed that you have installed CollEntRes C++ library on your clean Ubuntu 16.04 system, installed JetBrains CLion IDE, simple_website project, MySQL server with required databases and successfully compiled simple_website executable that runs without errors. If not, then follow instructions from the previous two steps.

Apache Installation

In this step, you will install Apache web server. Of course, you may use any web server that is able to connect to an independent server (in our case, it is simple_website executable that accepts incoming connections from the web server) via TCP (or UNIX socket) and communicate with it via FastCGI protocol. Just try to make it work with Apache and then you will know how to make it work on other web servers.

Install Apache web server by executing the following command in Terminal:

# apt-get install apache2

Simple Website's Virtual Host Creation

Enable some modules by executing the following command in Terminal:

# a2enmod proxy_fcgi rewrite expires headers

Create /etc/apache2/sites-available/simple-website.conf file and past the following code there:

<VirtualHost *:80>
	ServerName simple-website.local.com
	DocumentRoot /home/user/CLionProjects/simple_website/www

	# Proxy requests for dynamic content to the website executable.
	ProxyPassMatch ^/simple_website/(.*)$ fcgi://$1

	# Allow access to website root folder.
	<Directory "/home/user/CLionProjects/simple_website/www">
		Options Indexes FollowSymLinks

		# Do not allow .htaccess file
		AllowOverride None

		# Allow all IPs to use folder
		Require all granted

	# Internal URL redirect.
	RewriteEngine on
	RewriteCond %{REQUEST_URI} !^/assets/
	RewriteCond %{REQUEST_URI} !^/uploads/
	RewriteRule ^(.*)$ /simple_website$1 [L,PT]

	# Configure content caching.
	<IfModule mod_expires.c>
		# Enable expirations.
		ExpiresActive On

		# Cache all files for 2 weeks after access (A).
		ExpiresDefault A1209600

		<LocationMatch ^/simple_website>
			ExpiresActive Off
	<IfModule mod_headers.c>
		# Disable ETag
		Header unset ETag
		FileETag None

Save simple-website.conf file and execute the following commands in Terminal in order to make Apache load and use this new file:

# a2ensite simple-website
# service apache2 restart

If Apache does not start, then check whether port 80 is being used by some other program and terminate it.

Open /etc/hosts file and add the following line to the end of the file:       simple-website.local.com

Running and Testing Simple Website

Open simple_website project in CLion and run simple_website executable by executing Run -> Run... command. You shouldn't see any errors, if you didn't see them in the previous step.

So simple_website is running, is listening for incoming connections from the web server and is ready to process client requests. Open your browser, enter simple-website.local.com in the address input field and press Enter. If everything is OK, then you should see the main page of your Simple Website.


So you have successfully installed Simple Website on your development machine. Is is recommended for you to learn the code of each file of simple_website project, find out how it works and what is it for. All the documentation you have is the project files and CollEntRes C++ header files (they can be found in /usr/include/collentres folder), which have a lot of comments in each class. If you learn how every component of Simple Website works, then you will be able to create your own websites, which use CollEntRes C++ library.