Configure Apache to host Cassandra Universal Driver

Ultra-fast configuration

Assuming cgi.load is in /etc/apache2/mods-enabled/ and the server was restarted.

git clone the repository, and copy client_samples/ to /var/www

copy cgi-bin/ to /usr/lib/cgi-bin/

git clone the Datastax python driver

copy cassandra/ folder from Datastax python driver to /urs/lib/cgi-bin/ as well


Better configuration

Create a new virtual host file in /etc/apache2/sites-available/cassandradriver.conf

Assuming you want to listen on internal Ip address, same of your project’s code webwerver, on port 1714, and enabling cgi-bin:


    DocumentRoot /www/cassandra-universal-driver
    <Directory /www/cassandra-universal-driver/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny

    ScriptAlias /cgi-bin/ /www/cassandra-universal-driver/cgi-bin/
    <Directory "/www/cassandra-universal-driver/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order deny,allow
            Deny from all
            Allow from ::1/128

    ErrorLog ${APACHE_LOG_DIR}/cassandradriver-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/cassandradriver-access.log combined

Edit /etc/apache2/ports.conf to add:

Listen 1714

Create a symbolic link:

$ sudo ln -s /etc/apache2/sites-available/cassandradriver.conf /etc/apache2/sites-enabled/
sudo service apache2 restart

In the past configuration we assume you want to be able to test your scripts in root, and invoke the driver by using cgi-bin folder, that we restricted to reply only to internal addresses.

For example, your sample.php script in root will request:

Ensure in /www/cassandradriver/cgi-bin/ you have the file with execution permissions (chmod +x) and the folder cassandra/

Ensure you activated the cgi module on apache2:

Look at /etc/apache2/mods-enabled and see if there is a symlink to /etc/apache2/mods-available/cgi.load

If it does not exist, create it:

sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/


Why I suggest to use another port rather than 80?

It is suggested to use another port for C.U.D., rather than 80 for security.

If you do something wrong in your Virtualhost section of Apache and you are not blocking incoming petitions, you’ll be incurring in a heavy security problem. While if the ports of the Firewall are blocking all the traffic except 80, 443 and SSH if you make a mistake in Allow and Deny polices and listening Ip addresses, the Firewall will block the traffic anyway.


Leave a Reply

Your email address will not be published. Required fields are marked *