Friday, July 22, 2011

apache cgi enabled site on specific dir

As an example, using /home/username/some_test_dir/, although it's obviously better not to use home dirs for this kind of things.

These settings allow you to access the files in /home/username/some_test_dir on the web by localhost/some_web_dir (set in alias).
And also enables you to run cgi scripts there.
In the shell:
a2enmod cgi #enable cgi
a2ensite site-filename
/etc/init.d/apache2 reload #in debian

Where filename, is the name of a file containing the following text, placed in /etc/apache2/sites-available/:
<VirtualHost *:80>

 DocumentRoot /home/username/some_test_dir/
 <Directory "/home/username/some_test_dir">
  AllowOverride None
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
         allow from all
                AddHandler cgi-script .cgi .pl .sh
        Alias /some_web_dir "/home/username/some_test_dir/"

 ErrorLog ${APACHE_LOG_DIR}/some_web_dir_error.log

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

 CustomLog ${APACHE_LOG_DIR}/some_web_dir_access.log combined

No comments:

Post a Comment