
First, of course, you need to have Crow C++ installed on your system. To do this, install the dependencies:
See here: How to Install Crow C++ on Windows. It’s more interesting to run it without Apache, using Crow’s built-in server by running the binary directly!
sudo apt install git build-essential cmake make libasio-dev g++sudo pacman -S git base-devel cmake asioNow clone, compile, and install Crow C++:
git clone https://github.com/CrowCpp/Crow
cd Crow
cmake . -B build -DCROW_BUILD_EXAMPLES=OFF -DCROW_BUILD_TESTS=OFF
sudo cmake --install buildIf you want, you can now remove the cloned repository:
cd .. && rm -rf CrowCpp
Make sure you have Apache installed with the correct read and write permissions.
sudo apt install apache2
sudo chown -R $USER:$USER /var/www/html/sudo pacman -S apache
sudo chown -R $USER:$USER /srv/http# Ubuntu
mkdir -p /var/www/html/crow
cd /var/www/html/crow
# Arch
mkdir -p /srv/http/crow
cd /srv/http/crow
main.cpp
#include <crow.h> // On Windows, use double quotes
int main(){
crow::SimpleApp app;
CROW_ROUTE(app, "/")([](){
return "Hello world";
});
app.port(18080).multithreaded().run();
} Compile: g++ main.cpp -o app and test: ./app. Then access it in your browser at: http://localhost:18080.
Use similar paths and commands on Arch.
systemd file:
sudo vim /etc/systemd/system/crow-app.service(or use your preferred editor).
Paste this inside:
On Arch, replace all instances of
/var/www/htmlwith/srv/http, and instead ofwww-data, use justhttpfor bothUserandGroup.
[Unit]
Description=Crow C++ Web Application
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/html/crow
ExecStart=/var/www/html/crow/app
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target Save and exit.
sudo systemctl daemon-reload
sudo systemctl enable crow-app
sudo systemctl start crow-app
sudo systemctl status crow-app # to check if it's running You should see something like this:

Enable the necessary modules:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests sudo vim /etc/httpd/conf/httpd.conf and uncomment (or add, if missing) the following lines:LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule rewrite_module modules/mod_rewrite.so Also, find (or add) the following line:
If it’s commented out (with a
#), remove the#to uncomment it.
Include conf/extra/httpd-vhosts.conf sudo vim /etc/apache2/sites-available/000-default.confsudo vim /etc/httpd/conf/extra/httpd-vhosts.confDelete everything inside and paste this:
On Arch, change
/var/www/htmlto/srv/httpand replace${APACHE_LOG_DIR}with/var/log/httpd.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Simple reverse proxy that removes the prefix
ProxyRequests Off
ProxyPreserveHost On
# Proxy for port 18080
ProxyPass /crow/ http://127.0.0.1:18080/
ProxyPassReverse /crow/ http://127.0.0.1:18080/
# Rewrite URLs to remove the /crow/ prefix
RewriteEngine On
RewriteRule ^/crow/(.*)$ http://127.0.0.1:18080/$1 [P,L]
RewriteRule ^/crow/?$ http://127.0.0.1:18080/ [P,L]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost> Enable rewrite mode, restart Apache, and test by accessing the URL:
On Arch, just restart with:
sudo systemctl restart httpd.
sudo pkill -f app # Optional if you haven't modified the binary
sudo a2enmod rewrite
sudo systemctl restart apache2
xdg-open http://localhost/crow/ Done! Now you can develop your applications with Crow!
Remember that whenever you modify the binary, you need to restart it using pkill:
sudo pkill -f app On Arch, prefer using these two commands instead:
sudo systemctl daemon-reexec # or daemon-reload if you didn’t modify the systemd binary
sudo systemctl enable --now crow-app.service To check the status:
sudo systemctl status crow-app.service