<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title>Parallels knowledgebase (KB)</title>
<link>http://kb.parallels.com/</link>
<description>Parallels knowledgebase (KB)</description>
<language>en</language>
<copyright>Copyright 2008 Parallels</copyright>
<pubDate>Wed, 10 Sep 2008 00:00:00 +0600</pubDate>
<lastBuildDate>Wed, 10 Sep 2008 00:00:00 +0600</lastBuildDate>
<webMaster>rt-team@parallels.com</webMaster>

<item>
<title><![CDATA[500 Internal server error appears when I try to call my cgi script by URL using a browser. What could it be in this case?]]></title>
<link>http://kb.parallels.com/en/430</link>
<description><![CDATA[<div id="article">
	




	<div id="kb" class="kb">
		<div class="article-container">
			<h2 class="title">500 Internal server error appears when I try to call my cgi script by URL using a browser. What could it be in this case?</h2>
			<div class="ab-frame"><div class="bl"><div class="br"><div class="tl"><div class="tr"><!-- frame -->
				<div class="articleProperty">
					<div>Article ID: 430&nbsp;</div>
					<div>Last Review: Feb,16 2009</div>
					<tr>
						<td>Author: </td>
						<td>Hildreth Norohna</td>
					</tr>
					<br/>
					<tr>
						<td>Last updated by: </td>
						<td>Hildreth Norohna</td>
					</tr>
				</div><!-- articleProperty -->
			</div></div></div></div></div><!-- frame -->

			<div class="article-internal-flag"></div>

			<div id="article-content">
				<div class="article-part">
					<h2>Resolution</h2>
					1. Check <span style='font-family: courier new,courier;font-size: 12px;'>/etc/httpd/logs/suexec_log</span> or <span style='font-family: courier new,courier;font-size: 12px;'>/var/log/httpd/suexec_log</span> for errors while attempting to run CGI scripts. Suexec catches permission and ownership errors. <br /><br />Make sure that the cgi-bin/ folder has the following permissions and ownership:<br /><br /><span style='font-family: courier new,courier;font-size: 12px;'>drwxr-x--- myuser psaserv cgi-bin</span><br /><br />The script itself must be owned by domain FTP user but group must be 'psacln':<br /><br /><span style='font-family: courier new,courier;font-size: 12px;'>-rwxr-xr-x myuser psacln script.cgi</span><br /><br />Make sure that the permissions of the script file and the directory tree (relative to the server's document root) are set not higher than 755 or user: read, write, execute; group: read, execute; other: read, execute (-rwxr-xr-x).<br /><br />2. Plesk uses it's own <strong>suexec</strong> file and it might have been replaced by the original one that comes with standard apache package. In this case you need to restore it using the command:<br /><div class="commandline"><code># /bin/cp /usr/sbin/psa-suexec /usr/sbin/suexec</code></div><br />If SuSe 9.x is being used then /usr/sbin/suexec2 should be replaced with the original one.<br /><div class="commandline"><code># /bin/cp /usr/sbin/psa-apache2-suexec /usr/sbin/suexec2</code></div><br />For Debian operation system please use this command line:<br /><div class="commandline"><code># /bin/cp /opt/psa/suexec/psa-suexec2 /usr/lib/apache2/suexec2</code></div><br />For details how to upgrade Apache on the Plesk based server please follow <a href="http://kb.parallels.comfile:///V:/SWSoft/2009_02_16_Knowledge%20Base_round3_eng-deu/en/762">article 762</a>. <br /><br />3. Script may contain Windows carriage-return symbols at the end of each line which were not removed when you uploaded file onto the server by FTP from Windows workstation.<br /><br />End of lines in files are marked with 'carriage-return' (CR) and line-feed (LF) hidden characters on Windows systems, while Unix systems mark end of line with LF character only. <br /><br />It is needed to upload text files in ASCII transfer mode from Windows box, in this case CR,LF characters will be replaced with LF only. If CGI scripts are uploaded in BINARY mode, the files are uploaded as is without converting. When script is executed, CR characters are recognized as part of text and are not interpreted correctly, for example:<br /><br /><span style='font-family: courier new,courier;font-size: 12px;'>#!/usr/bin/perl<strong>CR</strong></span><br /><span style='font-family: courier new,courier;font-size: 12px;'>use strict;<strong>CR</strong></span><br /><br />You can also set the default transfer mode to ASCII server wide in the /etc/proftpd.conf file:<br /><br /><span style='font-family: courier new,courier;font-size: 12px;'>DefaultTransferMode ascii</span><br /><br />To check and correct already uploaded script with CR characters manually use one of the following variants:<br /><br />a) remove CR with <strong>col</strong> utility:<br /><div class="commandline"><code># cd /home/httpd/vhosts/domain.com/cgi-bin<br /># col -bx &lt; script.cgi &gt; script2.cgi<br /># ls -l<br />total 84<br />-rw-r--r-- 1 myuser psacln 27683 Jun 14 15:51 script2.cgi<br />-rwxr-xr-x 1 myuser psacln 25753 Jun 14 11:20 script.cgi<br /># mv script2.cgi script.cgi<br />mv: overwrite `script.cgi'? y<br /># chmod 755 script.cgi<br /># chown myuser:psacln script.cgi</code></div><br />Please use name of the script's owner instead of myuser.<br /><br />b) open file in <strong>pico</strong> text editor and save it then, it will remove CR symbols from the file.<br /><div class="commandline"><code># pico script.cgi</code></div><br /><br />4. Run the script from the command line and check for errors. <br />Examples:<br />&nbsp;<div class="commandline"><code># cd /home/httpd/vhosts/domain.com/cgi-bin<br /># ./script.cgi<br />: bad interpreter: No such file or directory</code></div><br />Check the script to make sure that magic comment specifies where perl is located: <span style='font-family: courier new,courier;font-size: 12px;'>#!/usr/bin/perl</span> and/or check for CR symbol in the end of <span style='font-family: courier new,courier;font-size: 12px;'>#!/usr/bin/perl</span> line, as described in option 3.<br /><br />or<br /><div class="commandline"><code># ./script.cgi<br />String found where operator expected at sc.cgi line 3, near &quot;xcprint &quot;&quot;&quot;<br />(Do you need to predeclare xcprint?)<br />syntax error at sc.cgi line 3, near &quot;xcprint &quot;&quot;&quot;<br />Execution of sc.cgi aborted due to compilation errors.</code></div><br />This example shows that there is some syntax error in this script and it won't work until you correct it.
				</div>
				<div class="keywords"><strong>Keywords:</strong> cgi script problem error 500 Internal server error</div>
			</div>
		</div><!-- article-container -->


			<br/><br/>

			<div id="SubscriptionLink24Article" class="subscriptionLink2">
<a href="http://kb.parallels.com/subscriptions/index.html?Type=Article&ArticleID=430&ArticleLanguage=en&Product=&Category="><img src="http://kb.parallels.com/images/mail.png" width="15" height="15" alt="Subscription for changes to this article"></a>
<a href="http://kb.parallels.com/subscriptions/index.html?Type=Article&ArticleID=430&ArticleLanguage=en&Product=&Category=">Subscription for changes to this article</a>

<script type="text/javascript">

$(document).ready(function() {
	$('#SubscriptionLink24Article a').each(function(){
		$(this).click(function(event) {
			event.preventDefault();
			MainPageContentHide();
			$('#subscription').html('');
			$.get('/Stuff/Subscription', {
													'Type' : 'Article',
													'ArticleID' : '430',
													'ArticleLanguage' : 'en',
													'Product' : '',
													'Category' : ''
												}, function(data) {
																	$('#subscription').html(data);
																	$('#subscription').show();
																	SUBbuildsubmenus_product();
																});
		});
	});
});

</script>

</div>





	</div><!-- kb -->

</div><!-- article -->


]]></description>
<author>Hildreth Norohna</author>
<guid isPermaLink="false">6390 LastUpdated: 2009-02-16 18:32:20</guid>
<pubDate>2009-02-16 18:32:20</pubDate>
</item>
</channel>
</rss>



