Guide to compiling and using the high-performance TextCounter C++ program.
tar xzf textcounter-cpp.tar.gz
cd textcounter-cpp
Open textcounter.cpp and edit the DATA_FILE constant:
const char* DATA_FILE = "/var/www/data/counter.dat";
g++ -O2 -o textcounter textcounter.cpp
touch /var/www/data/counter.dat
chmod 666 /var/www/data/counter.dat
cp textcounter /usr/local/apache/cgi-bin/
chmod 755 /usr/local/apache/cgi-bin/textcounter
Use with Server Side Includes:
<!--#exec cgi="/cgi-bin/textcounter"-->
You are visitor number <strong><!--#exec cgi="/cgi-bin/textcounter"--></strong>
<!-- Multiple counters for different pages -->
<!--#exec cgi="/cgi-bin/textcounter?page=home"-->
The C++ version implements solid file locking to prevent count corruption under concurrent access. This matters for high-traffic sites where multiple requests may occur simultaneously.
-O3 optimization flag for maximum speed-std=c++11 flag for modern C++ features.