<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Control WebPanel Wiki &#187; cgi-scripts</title>
	<atom:link href="https://wiki.centos-webpanel.com/tag/cgi-scripts/feed" rel="self" type="application/rss+xml" />
	<link>https://wiki.centos-webpanel.com</link>
	<description>CentOS WebPanel Wiki</description>
	<lastBuildDate>Wed, 12 Feb 2025 20:38:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>How to run cgi scripts with Apache</title>
		<link>https://wiki.centos-webpanel.com/how-to-run-cgi-scripts-with-apache</link>
		<comments>https://wiki.centos-webpanel.com/how-to-run-cgi-scripts-with-apache#comments</comments>
		<pubDate>Wed, 28 Jun 2017 17:59:30 +0000</pubDate>
		<dc:creator><![CDATA[publisher]]></dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[cgi-scripts]]></category>

		<guid isPermaLink="false">http://wiki.centos-webpanel.com/?p=823</guid>
		<description><![CDATA[How to run cgi scripts with Apache In this example we will add support for the following file extensions: .cgi .pl .py We have set folder to be /home/*/public_html/cgi-bin/ as this is by default, don't set it to as public_html only as this will cause issues with your php scripts. Create File: /usr/local/apache/conf.d/mod_cgid.conf LoadModule cgid_module [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><strong>How to run cgi scripts with Apache</strong><br />
In this example we will add support for the following file extensions: .cgi .pl .py<br />
We have set folder to be <strong>/home/*/public_html/cgi-bin/</strong> as this is by default, don't set it to as public_html only as this will cause issues with your php scripts.</p>
<div class="st-alert st-alert- "><a href="/how-to-enable-mod_suexec-with-apache" title="How to enable mod_suexec with CentOS WebPanel" target="_blank">Please don't forget to enable mod_suexec for security reasons if you will have with multiple sites.</a>
</div>
<p><strong>Create File:</strong> /usr/local/apache/conf.d/mod_cgid.conf</p>
<pre>LoadModule cgid_module modules/mod_cgid.so

&lt;IfModule cgid_module&gt;
&lt;Directory /home/*/public_html/cgi-bin/&gt;
Options ExecCGI SymLinksifOwnerMatch
SetHandler cgi-script
AddHandler cgi-script .cgi .pl .py
Require all granted
AllowOverride All
&lt;/Directory&gt;
&lt;/IfModule&gt;
</pre>
<p>Now restart apache and you are ready to run your cgi-scripts.</p>
<pre>service httpd restart</pre>
<p>
<strong>Test if cgid module is now loaded</strong></p>
<pre>/usr/local/apache/bin/httpd -M|grep cgid</pre>
<p>If module is loaded, you should get output containing this: <strong>cgid_module (shared)</strong></p>
<p>For perl you might also need to install it:</p>
<pre>yum install perl-CGI</pre>
<p>If you will have multiple domains or users on the server then its highly recommended that you enable suexec module for additional security.</p>
<p><strong>Test if suexec module is now loaded</strong></p>
<pre>/usr/local/apache/bin/httpd -M|grep suexec</pre>
<p>If module is loaded, you should get output containing this: <strong>suexec_module (shared)</strong><br />
<a href="http://wiki.centos-webpanel.com/how-to-enable-mod_suexec-with-apache" title="How to enable mod_suexec with CentOS WebPanel" target="_blank">http://wiki.centos-webpanel.com/how-to-enable-mod_suexec-with-apache</a></p>
<p><strong>Example test script</strong><br />
You can save it to your /home/USERNAME/public_html/cgi-bin/ folder.</p>
<p>Example File: /home/cwppro/public_html/cgi-bin/test.cgi<br />
URL: http://www.centos-cwppro.com/cgi-bin/test.cgi</p>
<pre>
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "Hello, world!\n";
system("whoami");</pre>
<p><em>This example will also show you if you are running the script as nobody user or real domain owner. If username is shown as nobody then you don't have mod_suexec running and scripts will run as nobody user. If you want that real user (owner) is running the script then please enable mod_suexec.</em></p>
<p><strong>What is a CGI file?</strong></p>
<p>CGI stands for Common Gateway Interface. Files that contain the .cgi file extension are are script files that are written in the C or Perl programming languages. These files are used to create web pages and they are usually stored within the cgi-bin folder of a website directory. The files define how web server software delegates the generation of certain web pages including executable files and stand-alone applications. These are often referred to as CGI scripts.</p>
<p>CGI scripts can be written in any programming language, but scripting languages are most commonly used to create these pages. CGI files are commonly used to run basic Web scripts, enabling website features such as integrated email message forms and rotating advertisements.</p>
<p><em>This info is for CWP Apache version 2.4.26-2 or later</em></p>
]]></content:encoded>
			<wfw:commentRss>https://wiki.centos-webpanel.com/how-to-run-cgi-scripts-with-apache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
