<?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>VerySimple &#187; Apache</title>
	<atom:link href="http://verysimple.com/category/web-servers/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://verysimple.com</link>
	<description>Custom Software</description>
	<lastBuildDate>Tue, 15 May 2012 07:40:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Your connection had to be retried using SSL 3.0 &#8211; Apache 2 SSL Certificate Configuration</title>
		<link>http://verysimple.com/2012/03/12/your-connection-had-to-be-retried-using-ssl-3-0-apache-2-ssl-certificate-configuration/</link>
		<comments>http://verysimple.com/2012/03/12/your-connection-had-to-be-retried-using-ssl-3-0-apache-2-ssl-certificate-configuration/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 04:45:33 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://verysimple.com/?p=1202</guid>
		<description><![CDATA[When viewing your SSL certification details in Chrome you may notice an annoying yellow warning icon with the error message &#8220;Your connection had to be retried using SSL 3.0 This typically means the server is using very old software and may have other security issues&#8221; This warning technically doesn&#8217;t affect or hurt anything but of [...]]]></description>
			<content:encoded><![CDATA[<p>When viewing your SSL certification details in Chrome you may notice an annoying yellow warning icon with the error message &#8220;Your connection had to be retried using SSL 3.0 This typically means the server is using very old software and may have other security issues&#8221;</p>
<p>This warning technically doesn&#8217;t affect or hurt anything but of course after paying for the SSL cert and going through the trouble of installing it, we all want our users to see the green lock icon and not a yellow warning icon!  If you&#8217;re running Apache2 the reason for this is that Chrome prefers to use TLS encryption but had to fall back to SSL encryption.  Apache2 supports TLS out of the box but may not be enabled by default.</p>
<p>To enable TLS, open your apache configuration file and add the two lines below:  (The config file is where you previously configured SSLCertificateFile and SSLCertificateKeyFile.  It&#8217;s possibly located in /etc/apache2/sites-enabled)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SSLProtocol <span style="color: #660033;">-all</span> +TLSv1 +SSLv3
SSLCipherSuite HIGH:MEDIUM:<span style="color: #000000; font-weight: bold;">!</span>aNULL:+SHA1:+MD5:+HIGH:+MEDIUM</pre></div></div>

<p>What these lines do is specify that both TLS version 1 and SSL version 3 are supported.  Once you&#8217;ve added these lines you need to restart Apache (/etc/init.d/apache2 restart).</p>
<p>If you refresh your browser at this point it&#8217;s likely that the warning icon is still there.   Shutting down and re-starting your browser should resolve it.  I suspect that the browser negotiates an SSL connection once and continues to use it until the session expires or the browser is restarted.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2012/03/12/your-connection-had-to-be-retried-using-ssl-3-0-apache-2-ssl-certificate-configuration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install Image Magick for PHP on OSX</title>
		<link>http://verysimple.com/2011/12/21/install-image-magick-for-php-on-osx/</link>
		<comments>http://verysimple.com/2011/12/21/install-image-magick-for-php-on-osx/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 05:34:56 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://verysimple.com/?p=1160</guid>
		<description><![CDATA[These instructions will install the ImageMagick binaries as well as the PHP extension for the default OSX Apache/PHP setup.  If you prefer not to use MacPorts there are binaries available, however you may have to deal with some dependencies and configuration on your own. 1. Install ImageMagick sudo port install ImageMagick 2. Install imagic module [...]]]></description>
			<content:encoded><![CDATA[<p>These instructions will install the ImageMagick binaries as well as the PHP extension for the default OSX Apache/PHP setup.  If you prefer not to use MacPorts there are binaries available, however you may have to deal with some dependencies and configuration on your own.</p>
<h3>1. Install ImageMagick</h3>
<p><code>sudo port install ImageMagick</code></p>
<h3>2. Install imagic module</h3>
<p>You&#8217;d expect to just be able to run &#8220;pecl install imagick&#8221; and I would probably try it first.  However the instructions below will work if the automatic installation returns the error: ImageMagick MagickWand API configuration program&#8230; configure: error: not found. Please provide a path to MagickWand-config or Wand-config program. ERROR: &#8216;/private/tmp/pear/temp/imagick/configure &#8211;with-imagick=/opt/local/bin/&#8217; failed.</p>
<p><em>Note version is 3.0.1 in these instructions, adjust the commands depending on the version that is downloaded by pecl.</em></p>
<p><code>pecl download imagick<br />
tar xvzf imagick-3.0.1.tgz<br />
cd imagick-3.0.1<br />
phpize<br />
./configure --with-imagick=/opt/local<br />
make<br />
sudo make install</code></p>
<p>The install process will create a file &#8220;imagick.so&#8221;, but it may not be automatically installed in the correct location depending on your PHP path settings.  The install will output the location of the .so file so if necessary, you can manually move that file to the extensions directory for your web server.</p>
<h3>3. Append to php.ini</h3>
<p><code>extension=imagick.so</code></p>
<p>That should be it.  Restart Apache and view phpinfo.php. There should be a section for ImageMagick</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2011/12/21/install-image-magick-for-php-on-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing LAMP Stack on OSX 10.7 Lion</title>
		<link>http://verysimple.com/2011/08/18/installing-lamp-stack-on-osx-10-7-lion/</link>
		<comments>http://verysimple.com/2011/08/18/installing-lamp-stack-on-osx-10-7-lion/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 22:14:41 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://verysimple.com/?p=998</guid>
		<description><![CDATA[This is a follow-up to my previous article on installing a LAMP Stack on Snow Leopard and explains the steps that you need to get Lion up and running for LAMP development.  (Linux, Apache, MySQL and PHP in case you don&#8217;t already know).  Lion comes pre-installed with Apache and PHP 5.3.6 so you only need [...]]]></description>
			<content:encoded><![CDATA[<p>This is a follow-up to my previous article on <a href="http://verysimple.com/2009/09/18/installing-lamp-stack-on-osx-10-6-snow-leopard/" target="_blank">installing a LAMP Stack on Snow Leopard</a> and explains the steps that you need to get Lion up and running for LAMP development.  (Linux, Apache, MySQL and PHP in case you don&#8217;t already know).  Lion comes pre-installed with Apache and PHP 5.3.6 so you only need to enable those features.  MySQL is the only component that you have to install.</p>
<h3>1.Turn on Apache</h3>
<p>Go to System Settings-&gt;Sharing and turn on Web Sharing. If necessary click the button that says &#8220;Create Home Folder&#8221; which will create a folder called &#8220;Sites&#8221; in your home directory.  You now have a web server that you can access at http://localhost/~username/  (&#8220;username&#8221; being your own account login name)</p>
<h3>2. Edit /private/etc/apache2/httpd.conf</h3>
<p>To enable PHP uncomment (remove the number sign at the beginning of) the line:</p>
<p>#LoadModule php5_module libexec/apache2/libphp5.so</p>
<p>(optional) you can re-map the server root to your home website directory by editing DocumentRoot:</p>
<p>DocumentRoot “/Users/username/Sites”</p>
<p>If you wish to use .htaccess files then look a bit further down AllowOverride and set it to &#8220;All&#8221; like so:</p>
<p>Options FollowSymLinks<br />
AllowOverride All<br />
Order deny,allow<br />
Deny from all</p>
<h3>3. Edit /private/etc/apache2/users/username.conf</h3>
<p>Your user directory has it&#8217;s own permissions as well which are located in this separate file.  You may wish to enable FollowSymLinks and AllowOverride again here by changing these two lines like so:</p>
<p>Options Indexes MultiViews FollowSymLinks<br />
AllowOverride All</p>
<h3>4. Copy /private/etc/php.ini.default to /private/etc/php.ini</h3>
<p>OSX includes a default php.ini file that you can use but you must rename or copy it first.  If you don&#8217;t do this then PHP will still run but it will just be using the default initialization settings with no way for you to override them.</p>
<p>Edit these settings in <strong>php.ini</strong> (some of these settings will not come into play until they are installed)</p>
<p>display_errors = On<br />
mysql.default_socket = /tmp/mysql.sock<br />
pdo_mysql.default_socket=/tmp/mysql.sock<br />
date.timezone = &#8216;America/Chicago&#8217;<br />
include_path = &#8220;.:/usr/lib/php/pear&#8221;</p>
<h3>5. (Optional) Install PEAR</h3>
<p>If you use the PEAR libraries you can install them using the included phar file like so:</p>
<p>sudo php /usr/lib/php/install-pear-nozlib.phar<br />
sudo pear config-set php_ini /private/etc/php.ini<br />
sudo pecl config-set php_ini /private/etc/php.ini<br />
sudo pear upgrade-all</p>
<h3>6.  Install MySQL</h3>
<p>This doesn&#8217;t really require instructions, simply download the latest MySQL from <a href="http://mysql.com/">mysql.com</a>.  I installed the 64 bit version.</p>
<h3>7. (Optional) Install Apache Plugins</h3>
<p>If you use encryption you may need to install mcrypt.  <a href="http://michaelgracie.com/2011/07/21/plugging-mcrypt-into-php-on-mac-os-x-lion-10-7/" target="_blank">Instructions</a> have been provided by Michael Gracie</p>
<p>If you use the Zend debugger you can install that using <a href="http://verysimple.com/2011/08/16/installing-zend-php-debugger-in-eclipse-on-osx/" target="_blank">these instructions</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2011/08/18/installing-lamp-stack-on-osx-10-7-lion/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Working with dates in Flex AIR and SQLite</title>
		<link>http://verysimple.com/2008/09/09/working-with-dates-in-flex-air-and-sqlite/</link>
		<comments>http://verysimple.com/2008/09/09/working-with-dates-in-flex-air-and-sqlite/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 21:38:49 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=149</guid>
		<description><![CDATA[UPDATE 3/25/09: Paul Robertson from the AIR team stopped by and writes that declaring your SQLite column affinity (ie column type) as &#8220;DATE&#8221; will instruct AIR to handle all date conversions for you automatically.  The problems I experienced mainly surfaced in a DataGrid when using a DateField and I have not had a chance to [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE 3/25/09: Paul Robertson from the AIR team stopped by and writes that declaring your SQLite column affinity (ie column type) as &#8220;DATE&#8221; will instruct AIR to handle all date conversions for you automatically.  The problems I experienced mainly surfaced in a DataGrid when using a DateField and I have not had a chance to poke around with that yet.  Another approach is to extend DateField and override the &#8220;data&#8221; setter which is how the DataGrid supplies item editors with their value.  Then you can deal with casting issues manually, however that may be more of a hack.  The article below still has some good information that is still helpful for dealing with Dates in AIR/SQLite.</p>
<p>Working with SQLite and Flex/AIR Date values can be tricky and various caveats are not particularly well documented.  The confusion (for me) is that ActionScript is loaded with UTC functions, and SQLite will happily insert them into DATETIME columns.  Everything appears fine, however SQLite does not actually recognize this format as a Date and treats it as plain text.  You have no way to see this happened until you try to apply some date formatting functions and notice SQLite returning NULL.  SQLite is so lax about data integrity that you can insert anything into any column type and will never receive any warnings.  AIR, though, will attempt to cast values behind the scenes based on column types and so you will run into &#8216;Invalid Date&#8217; errors and weird glitches when attempting to update data.</p>
<p>The magic solution is the <a href="http://en.wikipedia.org/wiki/Julian_Day_Number">Julian Date Format</a> which both SQLite and AIR recognize as a date value.  This is somewhat surprising as ActionScript has no built-in support for outputting Julian dates.  If you&#8217;re like me, you may have already hacked up workarounds using int fields with timestamps, however your matching ActionScript class properties have to be hacked to match, and the hacking can trickle down throughout your code.  This also prevents you from using the SQLStatement.itemClass functionality, which is nice when using Cairngorm, DAOs, value objects, etc.</p>
<p><strong>To avoid the pain follow these rules when working with dates:</strong></p>
<p>1. If you want a strongly typed Date field in AIR, the relevant SQLite column must be defined as DATETIME.  The interesting thing about this is that DATETIME is not technically a <a href="http://www.sqlite.org/datatype3.html" target="_blank">recognized SQLite column type</a> and according to the SQLite docs it will be considered numeric.  But AIR is obviously looking at the column definition somewhere in the framework because it will refuse to automatically cast any value where the column type is not DATETIME.</p>
<p>2. Whenever inserting or updating DATETIME fields, you must store it in Julian format (or NULL).   SQLite will happily accept many common date formats.  However AIR will behave inconsistently.  Here is how to insert Julian dates in a variety of ways:</p>
<p><em>Inserting a Julian date manually via SQL:</em></p>
<p>To do this, simply have SQLite format your date value to Julian format using &#8216;%J&#8217;</p>
<pre>UPDATE my_table SET my_column = STRFTIME('%J','2008-01-02 03:04:05')</pre>
<p><em>Inserting a Julian date via AIR (with parameters):</em></p>
<p>Parameters are the best way to build SQL statements as you can use strongly typed Date variables and AIR will deal with the formatting for you.</p>
<pre>statement.text = "UPDATE my_table SET my_column = :my_value";
statement.parameters[":my_value"] = new Date(2008,0,2,3,4,5); // Jan 02, 2008 03:04:05</pre>
<p><em>Inserting a Julian date via AIR (without parameters):</em></p>
<p>If you are not using parameters, you have to pre-format the date into something that SQLite can parse.  This is surprisingly obnoxious and requires you to write a couple of helper functions. (Note &#8211; if you know of an easier way to do this, please post a comment.)</p>
<pre>public function lpad(original:Object, length:int, pad:String):String
{
var padded:String = original == null ? "" : original.toString();
while (padded.length &lt; length) padded = pad + padded;
return padded;
}

public function toSqlDate(dateVal:Date):String
{
return dateVal == null ? null : dateVal.fullYear
+ "-" + lpad(dateVal.month + 1,2,'0')  // month is zero-based
+ "-" + lpad(dateVal.date,2,'0')
+ " " + lpad(dateVal.hours,2,'0')
+ ":" + lpad(dateVal.minutes,2,'0')
+ ":" + lpad(dateVal.seconds,2,'0')
;
}

var myDate:Date = new Date(2008,0,2,3,4,5); // Jan 02, 2008 03:04:05
statement.text = "UPDATE my_table SET my_column = strftime('%J','" + toSqlDate(myDate) + "')";</pre>
<p><strong>Fudging data to work around AIRs validation</strong></p>
<p>If you absolutely refuse to change your schema (for example you insist on using timestamps, or you have to maintain compatibility with other clients) you can get AIR to play along during READ operations by altering your select statement like so:</p>
<pre>SELECT STRFTIME('%J',my_column) as my_column from my_table</pre>
<p>This does assume that the data is in a format that SQLite recognizes as a date.  If SQLite can&#8217;t parse the date value, then it will just return NULL.  For hilarity sake, you can also use <a href="http://www.verysimple.com/blog/2008/09/08/rediculous-date-formatting-in-sqlite/">this ridiculous date format </a>which surprisingly works with AIR.  A word of warning about this workaround is that, even though you will be able to read data, you may not be able to update data via SQLCommand parameters if your column types are DATETIME because AIR will complain about an invalid date (see errors below).  You will have either have to write your own SQL statements without parameters or else change your column types to int or varchar.</p>
<p><strong>Formatting a Julian date manually in SQL so you can read it:</strong></p>
<p>Julian values are great and all that, but it&#8217;s pretty much impossible to eyeball them when you&#8217;re working at the command line.  SQLite recognizes Julian formatting as a valid date, so you can use the STRFTIME function to format and output it any way you like.  Below is a simple example that is easier to read:</p>
<pre>SELECT STRFTIME('%Y-%m-%d %H:%M:%S',my_column) as my_column_formatted FROM my_table</pre>
<p><strong>Common errors that occur while working with dates:</strong></p>
<p><em>Invalid Date</em></p>
<p>You may see this in a DataGrid instead of the expected date value.  This is because you have a DATETIME column in SQLite, however the value is not in Julian format.  Even though SQLite may recognize it as a date value, AIR does not.  The solution is to clean your data so that all dates are Julian format, or alternatively change the column type to VARCHAR.</p>
<p><em>&#8216;Error #3115: SQL Error.&#8217;, details:&#8217;could not convert string value to date&#8217;</em></p>
<p>This error occurs when you try to update a record that has one or more DATETIME columns that do not have the date stored in Julian format.  The weird part is that even if you are not touching that specific column in your insert/update statement &#8211; AIR will still validate the Date and throw this error. The solution is to clean your data so that all dates are Julian format, or alternatively change the column type to VARCHAR.</p>
<p>If you have any tips or corrections please post a comment and I&#8217;ll incorporate it into the article.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2008/09/09/working-with-dates-in-flex-air-and-sqlite/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Installing PHP To Run on Both IIS and Apache on Windows</title>
		<link>http://verysimple.com/2006/03/30/installing-php-to-run-on-both-iis-and-apache-on-windows/</link>
		<comments>http://verysimple.com/2006/03/30/installing-php-to-run-on-both-iis-and-apache-on-windows/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=9</guid>
		<description><![CDATA[Installing PHP to run on Windows through IIS is pretty simple because there is an installation wizard that does everything for you. But, those of us who also have Apache running for development need to have Apache process PHP pages too. This is a walkthrough to get both running. This will run PHP in CGI [...]]]></description>
			<content:encoded><![CDATA[<p>Installing PHP to run on Windows through IIS is pretty simple because there is an installation wizard that does everything for you.  But, those of us who also have Apache running for development need to have Apache process PHP pages too.  This is a walkthrough to get both running.</p>
<p>This will run PHP in CGI mode for both IIS and Apache.</p>
<p>1. Download from www.php.net the Windows Installer version of PHP AND the Windows &#8220;manual install&#8221; .zip distribution.  (If you already have PHP running for IIS, then you only need the zip version)</p>
<p>2. Run the PHP installer.  Install it to its default location of C:\PHP.  PHP should now be working with IIS.</p>
<p>3. Move the file C:\PHP\php.ini-dist to C:\Windows\php.ini</p>
<p>3. Unzip the &#8220;manual install&#8221; distribution.  You&#8217;ll notice that it has much of the same files as are already in C:\PHP.  Move all the of extra directories contained in this .zip to C:\PHP</p>
<p>4.  Download and install Apache HTTP server from www.apache.org.  (I used version 2).  Default install location is C:\Program Files\Apache Group\Apache2.  The configuration you use is up to you, but i specify in the install wizard to run Apache manually on port 8080 so that it will co-exist with IIS (which is already on port 80).  Then after that is done, I install it as a service by executing the command-line command:  apache -k install<br />
(from within the apache2\bin directory)</p>
<p>5. Edit the Apache configuration file C:\Program Files\Apache Group\Apache2\httpd.conf &#8211; make the following changes:</p>
<p># search for &#8220;DirectoryIndex&#8221; and add index.php to the end:<br />
DirectoryIndex index.html index.html.var index.php</p>
<p># search for &#8220;ScriptAlias&#8221; and add the following lines in that section:<br />
ScriptAlias /php/ &#8220;c:/php/&#8221;<br />
AddType application/x-httpd-php .php<br />
Action application/x-httpd-php &#8220;/php/php.exe&#8221;</p>
<p>6. restart Apache and the new configuration should take effect.  create a test PHP file and see how it works.</p>
<p>* caveat: if you use the same browser and surf back-and-forth between IIS and Apache, you may get a bunch of weird error messages about permission denied while writing session files.  This is because Apache and IIS run as different users &amp; they will block each other from writing to the same session file.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/installing-php-to-run-on-both-iis-and-apache-on-windows/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Securing your cgi-bin</title>
		<link>http://verysimple.com/2006/03/30/securing-your-cgi-bin/</link>
		<comments>http://verysimple.com/2006/03/30/securing-your-cgi-bin/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=11</guid>
		<description><![CDATA[The Problem: I find a lot of surprising security problems as I work on client&#8217;s sites. Even large, reputable companies often have gross security issues. I know more than anyone how difficult it can be to get a cgi script installed and working. It&#8217;s tempting to walk away without double-checking the security. One of the [...]]]></description>
			<content:encoded><![CDATA[<p>The Problem:</p>
<p>I find a lot of surprising security problems as I work on client&#8217;s sites.  Even large, reputable companies often have gross security issues.  I know more than anyone how difficult it can be to get a cgi script installed and working.  It&#8217;s tempting to walk away without double-checking the security.  One of the most common things that I see is poor security of the cgi-bin.  Depending on the setup of your server, someone can take total control of your account easily through a poorly secured cgi-bin.</p>
<p>The particular problem i&#8217;m writing about involves writable files/directories within your cgi-bin, or scripts that make calls to external programs (like sendmail).  These are both very common types of scripts that you would find in just about any cgi-bin.</p>
<p>The writable file issue is that most cgi scripts rely on a datafile to store their information.  In some cases, they need an entire writable directory to store data (file uploads, etc).  The tricky part is that you have to allow the script write access to the file/directory.  If your server is running as &#8220;nobody&#8221; then you need to allow world write access to the file.  This is dangerous because other users on the server also have the ability to run under the &#8220;nobody&#8221; user &#8211; which means they can also write to those files.  Some servers are configured so that scripts execute under your own userid.  Otherwise sensible people are fooled into thinking that they are protected by this.  Although it does protect you from the &#8220;nobody&#8221; exploits, it actually make the potential damage much worse if you have poor security settings.</p>
<p>The issue with scripts that make calls to external programs (like Formail for sending email via sendmail, etc) is that if they are not coded properly, someone can input malicious text that causes an arbitrary shell command to run in addition to the sendmail command.  This command will run under whatever userid that the original script has.</p>
<p>One dangerous situation is a script that allows file uploads and it&#8217;s writable directory is in the cgi-bin.  Any script like this should have serious security checks in place to prevent malicious files from being uploaded.  If the script doesn&#8217;t check file types as they upload, any anonymous user can upload a script or executable file right to your cgi-bin.</p>
<p>Another situation is on a virtual host where you share your account with lots of other users.  This exploit is only available to people who have an account on your machine, however it is no less a problem.  All users on your server can install cgi scripts in their account which run under the &#8220;nobody&#8221; permissions.  If they install a simple command processing script, they can manipulate any file in your account that allows world write access.</p>
<p>So, take a look at your cgi-bin and look for any writable files or directories.  Imagine what would happen if someone could edit or add any file there in your cgi-bin.  A writable directory is particularly bad because the other person on your server can actually write a new script file there and then browse to the url to execute it.</p>
<p>Normally if someone can totally compromise your site in this way, they are limited to running as the user &#8220;nobody.&#8221;  However, there is still quite a bit of damage that can be done.  Formmail scripts can be installed to send spam.  Scripts to snoop into your datafiles can be installed.  Large files can be uploaded and shared (using your bandwith).  I once had a client who incurred a $10,000 bandwidth bill after their server was compromised by hackers sharing video game software.  Nothing more than &#8220;nobody&#8221; access is needed to do this.</p>
<p>If cgi-wrap is enabled, the situation is compounded because the scripts in your cgi-bin can be executed through cgi-wrap to run under your own userid.  At that point, they own your account.</p>
<p>How To Secure cgi-bin:</p>
<p>There&#8217;s a few simple things that can help lock down your cgi-bin.</p>
<p>1. Never, ever have a file with both world-execute and world-write permissions.  This can be overwritten with any arbritrary code by any user on your server.  Once they overwrite, they can execute it through the browser.  Scripts themselves should never require write permission.  Read/Execute is fine (chmod 505 is nice and secure).</p>
<p>2. If possible, never have any writable directories or files in the cgi-bin.  Not even writable by your own user id.  there is no reason that a file needs to be writable within the cgi-bin.  Depending on what scripts you have installed, this can be challenging.  The solution is to move all datafiles to an area that is not accessible through the web browser.  If this is not possible, see # 3</p>
<p>3. If you must have writable files or folders in the cgi-bin because of the functionality of a script, keep them in a subdirectory and put an .htaccess file in there that has the contents &#8220;deny from all&#8221; in it.  Your scripts can still read/write files there, but nothing can be executed through the browser.  if you are not able to put them in a separate directory, you can deny access to specific files using .htaccess.</p>
<p>4. Never give any permissions to the &#8220;group.&#8221;  In UNIX you have three permissions to grant &#8211; owner, group, world.  for example, chmod 644 grants 6 (rw) to owner, 4 (r) to group and 4 (r) to the world.  The group is almost always other accounts on your server.  You generally do not know these other users and there is no reason to give them any permissions for any file in your account.  The middle value should always be zero.  for example: chmod 604 gives the group 0 (no access) which is fine.</p>
<p>5. be very careful when cgi-wrap is enabled or your cgi-bin executes using your own account&#8217;s userid.  in this case you have to make sure that nothing can be written arbitrarily into your cgi-bin even using your own account permissions.  Keep in mind that you do not need permission to write to a script.  You can remove the write permission even for yourself.  If you need to change it later, you first change the permission to allow write, then change it back.  It doesn&#8217;t need to sit there with write permissions.  You have to be very cautious about what scripts are installed, because any script with an exploit can be dangerous.  if someone can write or upload to your cgi-bin, they can create their own script and run it under you userid.  If you use cgi-wrap, there is no reason for the group or the world to have any permissions on your files.  so, you should change permissions something like this: chmod 400 (only you have read permission).  scripts can be chmod 500.  writable datafiles can be chmod 600, but should not be stored in a public area.  remember that if someone can run arbitrary code as your userid, they own your account!</p>
<p>6. Try to break into your own account.  Go through your scripts and try to upload a file that shouldn&#8217;t be allowed.  Look at scripst that send email and see if you can enter data in such a way that code gets executed.</p>
<p>Summary:</p>
<p>The moral of the story is to be cautious with your cgi-bin.  Especially look for writable files and directories.  Never trust other users on your server.  It may not seem important to take security seriously for your homepage with a bulletin board and formmail script.  But there are malicious people out there always scanning for easy targets.  Your data can be compromised or your bandwidth stolen &#8211; leaving you with the bill.  A little bit of extra time can save you a lot of grief later.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/securing-your-cgi-bin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install Apache + Subversion on Windows</title>
		<link>http://verysimple.com/2006/03/30/install-apache-subversion-on-windows/</link>
		<comments>http://verysimple.com/2006/03/30/install-apache-subversion-on-windows/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=18</guid>
		<description><![CDATA[How to Install Subversion Server on Windows using Apache This is a walkthrough to install subversion server on Windows and make it available over http using Apache. Subversion is a version control system. In combination with Apache, you can allow local and remote developers to share source code. This guide will use the following installation [...]]]></description>
			<content:encoded><![CDATA[<p>How to Install Subversion Server on Windows using Apache</p>
<p>This is a walkthrough to install subversion server on Windows and make it available over http using Apache.  Subversion is a version control system.  In combination with Apache, you can allow local and remote developers to share source code.</p>
<p>This guide will use the following installation paths.  You can change these as you like, but I&#8217;m going to use them in this walkthrough:</p>
<p>Apache = C:\Program Files\Apache Group\Apache2<br />
Subversion = C:\Program Files\Subersion<br />
Location of Repositories:  C:\InetPub\svn\<br />
Location of passfile: C:\InetPub\svn.pass<br />
URL for Repositories:  [url]http://localhost:8080/svn/[/url]</p>
<p>1. INSTALL APACHE</p>
<p>a. Download Apache from <a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a> <em>(Apache 2.0.55 is the current stable release at the time of this writing)</em></p>
<p>b. Run the Windows Installer.   The defaults are fine.  When you reach the Server Information dialog, you&#8217;ll be prompted to choose between installing on port 80 as a service, or on port 8080 with manual startup.   Choose the service option on port 80 (we will change the port in the next step).  Complete the install process accepting all defaults.</p>
<p>c. Since we are working on a Windows server, you probably already have IIS running on port 80.  So, we need to pick another for Apache &#8211; this is really easy to change.  Open the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf in notepad.exe.  Do a find (ctrl+f) for the word &#8220;listen&#8221; until you fine the line</p>
<p><code>Listen 80</code></p>
<p>Change the 80 to 8080  (or whatever port you want).  For this example, I&#8217;m going to be using port 8080</p>
<p>d. Save http.conf and restart Apache to reflect the changes.  You can do this through the services applet (Start -&gt; Run services.msc) or also through the apache service monitor (This is the apache icon next to the clock in the taskbar)</p>
<p>e. Test that Apache is running by going to [url]http://localhost:8080/[/url]   (you should get the default Apache welcome screen).</p>
<p>2. INSTALL SUBVERSION</p>
<p>a. Download The subervsion server binary for Windows.  It&#8217;s currently located at <a href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91">http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91</a><br />
For these instructions, download the svn-x.x.x-setup.exe installer.</p>
<p>b. Run the Subversion server setup.  All defaults are fine.  At a certain point you&#8217;ll see an option about installing Apache Modules.  As far as I can tell this does nothing, but whatever!  I left it checked.</p>
<p>3. CONFIGURE APACHE SUBVERSION MODULES</p>
<p>a. We need to move the subversion modules so Apache can use the.  To do that, copy the following files from C:\Program Files\Subversion\bin\ to C:\Program Files\Apache Group\Apache2\modules\</p>
<p>libdb42.dll<br />
libeay32.dll<br />
mod_authz_svn.so<br />
mod_dav_svn.so</p>
<p>b. Open C:\Program Files\Apache Group\Apache2\conf\httpd.conf again and do a find for &#8220;LoadModule&#8221; &#8211; This should take you to a section where there are a bunch  of LoadModule statements uncomment this line (delete the # from the beginning of the line):</p>
<p><code>LoadModule dav_fs_module modules/mod_dav_fs.so</code></p>
<p>Below that, add the following two lines:</p>
<p><code>LoadModule dav_svn_module modules/mod_dav_svn.so<br />
LoadModule authz_svn_module modules/mod_authz_svn.so</code></p>
<p>Now scroll to the very botton of the file and paste the following.</p>
<p><code>&lt;Location /svn&gt;<br />
DAV svn<br />
SVNParentPath  C:\InetPub\svn<br />
AuthType Basic<br />
AuthName "Subversion repositories"<br />
AuthUserFile C:\InetPub\svn.pass<br />
#AuthzSVNAccessFile svnaccessfile<br />
Require valid-user<br />
&lt;/Location&gt;</code></p>
<p>You can change these as you like, however this is what I&#8217;ll use for the instructions here.  I happen to think these are reasonable defaults.  The settings are probably somewhat self-explainitory, but for additional information read the fine Apache manual.</p>
<p>c. Restart Apache Again to load the configuration changes</p>
<p>d. Test that everything is working at this stage by going to [url]http://localhost:8080/svn/[/url]  You should get prompted for login box.  We haven&#8217;t created a username/password yet so just hit cancel.</p>
<p>4. CREATE A USERNAME/PASSWORD FOR HE APACHE DIRECTORY</p>
<p>a. We need to use htpasswd.exe in the Apache2/bin directory to edit the password files.  this is a pain unless it is in your path, so I recommend adding it to your environmental PATH variable.  (right-click My Computer -&gt; Advanced -&gt; Environmental Variables) Append the folling to the PATH variable:  ;C:\Program Files\Apache Group\Apache2\bin</p>
<p>b. Create a blank file C:\InetPub\svn.pass</p>
<p>c. Open a new DOS windows (you need to open a new one to recognize the PATH changes)</p>
<p>d. go to C:\InetPub and type the following:</p>
<p><code>htpasswd snv.pass svnuser</code></p>
<p>You&#8217;ll be prompted for a password.  enter whatever you want (svnpass for this example)</p>
<p>(This is the procedure you can repeat to add more users)</p>
<p>e. You can open svn.pass in notepad to make sure there is a user there &#8211; you should see &#8220;svnuser&#8221; followed by the crypted pass information.</p>
<p>5. CREATE A REPOSITORY</p>
<p>a. Open Windows explorer and create a folder C:\InetPub\svn</p>
<p>b. Open a DOS window and go to C:\InetPub\svn</p>
<p>c. Enter the following:</p>
<p><code>svnadmin create myrepository</code></p>
<p><em>(You can repeat this process to create additional repositories &#8211; I am just choosing the name myrepository for testing purposes)</em></p>
<p>d. Give it a test by opening [url]http://localhost:8080/svn/myrepository/[/url] and  entering the username/pass you created in step 4  (in this example svnuser / svnpass)  If everything is working right, then you should see &#8220;Revision 0&#8243; in the browser.</p>
<p>Contratulations &#8211; You&#8217;re Done!</p>
<p>6. USING YOUR REPOSITORY</p>
<p>If you need instructions for using subversion, I&#8217;d recommend downloading TortoiseSVN from <a href="http://tortoisesvn.tigris.org/">http://tortoisesvn.tigris.org/</a> and reading the documentation.  Although setting up the server is a bit of work, using the client is pretty easy.</p>
<p>When you use your client to connect to the server, your subversion repository will always start with http://your.domain.com/svn/ (as opposed to some public repositories that start with svn://your.domain.com/)  Otherwise, the usage is exactly the same.</p>
<p>If you haven&#8217;t managed a Subversion server, you may not know how to initialize your repository.  Basically, each time you create a new repository, you have to initialize it by doing an import.  You have to add at least one file to the repository.  To do this, just create a blank folder on your computer, put at least 1 file in there (I put a readme.txt or whatever).  Then use your subversion client &#8220;import&#8221; command.  This will initialize the repository at version 1.  At that point, you can check in and out as you always do.</p>
<p>THE END</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/install-apache-subversion-on-windows/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>PHP intermittent blank page</title>
		<link>http://verysimple.com/2006/03/30/php-intermittent-blank-page/</link>
		<comments>http://verysimple.com/2006/03/30/php-intermittent-blank-page/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[*NIX]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=42</guid>
		<description><![CDATA[There is a problem with IE and PHP applications is certain instances where an intermittent blank page appears instead of the expected content. This seems to relate to an earlier bug reported by Microsoft with IE 6 where the content length was reported as 0 during POST requests. This occured when browsing sites running UNIX/Apache [...]]]></description>
			<content:encoded><![CDATA[<p>There is a problem with IE and PHP applications is certain instances where an intermittent blank page appears instead of the expected content.</p>
<p>This seems to relate to an earlier bug reported by Microsoft with IE 6 where the content length was reported as 0 during POST requests.  This occured when browsing sites running UNIX/Apache with keepalive enabled.  However, I&#8217;ve discovered that the same problem occurs intermittently with certain PHP applications and GET requests.</p>
<p>One workaround which solves the problem (although with a performance hit) is to create an .htaccess file in the root directory with the following setting:</p>
<p>[code]<br />
BrowserMatch "MSIE" nokeepalive downgrade-1.0 force-response-1.0</p>
<p>SetEnvIf User-Agent ".*MSIE.*" \<br />
nokeepalive ssl-unclean-shutdown \<br />
downgrade-1.0 force-response-1.0<br />
[/code]</p>
<p>This workaround disables keepalive for all IE 6 clients.  I imagine this would have a negative performance effect, however it is likely preferable to a buggy application.</p>
<p>I haven&#8217;t been able to determine if certain PHP code techniques could be causing the problem.  I read certain people presuming that it could be session related, however, i went as far as removing all session functionality from an application, however it did not solve the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/php-intermittent-blank-page/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>set php allow_call_time_pass_reference in .htaccess</title>
		<link>http://verysimple.com/2006/03/30/set-php-allow_call_time_pass_reference-in-htaccess/</link>
		<comments>http://verysimple.com/2006/03/30/set-php-allow_call_time_pass_reference-in-htaccess/#comments</comments>
		<pubDate>Thu, 30 Mar 2006 10:00:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=48</guid>
		<description><![CDATA[I just spent about an hour trying to figure this out, but when you have a php application that requires call time pass reference to be enabled, you can set in the .htaccess file.  The trick on some systems is that it must be set to &#8220;1&#8243; and not &#8220;on&#8221; as is indicated on the [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent about an hour trying to figure this out, but when you have a php application that requires call time pass reference to be enabled, you can set in the .htaccess file.  The trick on some systems is that it must be set to &#8220;1&#8243; and not &#8220;on&#8221; as is indicated on the PHP support forums.  here&#8217;s the code:</p>
<pre>php_flag allow_call_time_pass_reference 1</pre>
<p>Whether or not you need to use &#8220;1&#8243; or &#8220;on&#8221; seems to depend on the install and whether you&#8217;re using PHP version 4 or 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://verysimple.com/2006/03/30/set-php-allow_call_time_pass_reference-in-htaccess/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

