DEV Community

Ahmad Adillaumam
Ahmad Adillaumam

Posted on

Apache setup for C++ .cgi (Ubuntu)

Enable CGI module

$ sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/
Enter fullscreen mode Exit fullscreen mode

Add this configuration inside <Directory /var/www/> on /etc/apache2/apache2.conf

<Directory /var/www/>
  Options +ExecCGI
  AddHandler cgi-script .cgi
</Directory>
Enter fullscreen mode Exit fullscreen mode

Restart Apache2

$ systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Compile your cpp file and put to /var/www/html/

$ sudo g++ FILENAME.cpp -o /var/www/html/FILENAME.cgi
Enter fullscreen mode Exit fullscreen mode

Top comments (0)