Setup apache webserver on CentOS
sudo yum install httpd
To make this web server available from lan or we need to whitelist our interfaces as Listen *:80
in /etc/httpd/conf/httpd.conf
Now, we setup CGI execution, change the directory settings in
httpd.conf
Before restarting
httpd we have to change one more thing inside /etc/httpd/conf/httpd.conf:<Directory "var/www/html">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>
Change permissions to allow for CGI to execute
And this one got me stuck a lot! Don't overlook this!
You need to tell your server that these CGI scripts are allowed to be executed as programs.
chmod 705 *.cgi
Or you can target individual CGI scripts.
chmod 705 hello.cgi
Put cgi files in /var/www/cgi-bin/ and run as http://serverip/cgi-bin/script.cgi
cat /etc/httpd/conf/httpd.conf | grep ScriptAlias should have something like this in the output
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
This is enough to run a test cgi script.
In case aces you might need to install more packages for a particular script such as MD5 digest.
# sudo yum install perl-Digest-MD5 -y
Now Reboot Apache : sudo apachectl stop, sudo apachectl start
No comments:
Post a Comment