<?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>Justin Carmony &#187; Apache</title>
	<atom:link href="http://www.justincarmony.com/blog/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.justincarmony.com/blog</link>
	<description>Web Designer &#38; Software Engineer</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:30:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP, Nginx, and Output Flushing</title>
		<link>http://www.justincarmony.com/blog/2011/01/24/php-nginx-and-output-flushing/</link>
		<comments>http://www.justincarmony.com/blog/2011/01/24/php-nginx-and-output-flushing/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 04:01:00 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=726</guid>
		<description><![CDATA[Alright, so one of the few hangups I&#8217;ve ran into with moving from Apache to Nginx was output buffering. Now, we have a few administrative tools we use to perform large operations on our library and data. These scripts can take normally 3-5 minutes to run, and they output their progress and what step they ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/06/23/php-practices-buffering-your-autoload/' rel='bookmark' title='PHP Practices: Buffering your autoload'>PHP Practices: Buffering your autoload</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/09/21/swiftmailer-sending-mail-in-php-with-ease/' rel='bookmark' title='SwiftMailer &#8211; Sending Mail in PHP With Ease'>SwiftMailer &#8211; Sending Mail in PHP With Ease</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/nginx-logo.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/nginx-logo-300x77.png" alt="" title="nginx-logo" width="300" height="77" class="alignright size-medium wp-image-728" /></a>Alright, so one of the few hangups I&#8217;ve ran into with moving from <a href="http://httpd.apache.org/">Apache</a> to <a href="http://nginx.org/">Nginx</a> was output buffering. Now, we have a few administrative tools we use to perform large operations on our library and data. These scripts can take normally 3-5 minutes to run, and they output their progress and what step they are on as they run. The way they do this is after ever step in PHP I issue the same two commands:</p>
<pre class="brush: php; title: ; notranslate">
ob_flush(); // Flush anything that might be in the header output buffer
flush(); // Send contents so far to the browser
</pre>
<p>Well, with Nginx, it will wait for an entire response from the PHP-FPM instance before sending data to the browser. This is because traditionally the time to generate the response is less than the time to send the response to the browser, so Nginx will let the CGI instance finish as quick as possible to free it up for other requests. Well, even if I called ob_flush() and flush(), Nginx would wait for the entire response before sending it to the client&#8217;s browser. So, for our staff panel, I had to disable this buffering. It took a lot of scouring the web, but I finally figured it out:</p>
<h3>Nginx Configuration</h3>
<p>You need to set a few variables. I couldn&#8217;t actually figure out how to disable the buffer for Nginx, but I could set it very low on a per location configuration. </p>
<p>So I have the following location configurations:</p>
<code class="code">location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /path/to/public_html/$fastcgi_script_name;
        fastcgi_read_timeout 600;
        fastcgi_buffer_size   1k;                              
        fastcgi_buffers       128 1k;  # up to 4k + 128 * 4k
        fastcgi_max_temp_file_size 0;
        gzip off;
    }</code>
<p>The important configurations are:</p>
<code class="code">fastcgi_buffer_size   1k;                              
fastcgi_buffers       128 1k;  # up to 1k + 128 * 1k
fastcgi_max_temp_file_size 0;
gzip off;</code>
<p>So I set the fastcgi_buffer_size and buffers to 1k. Then, you need to set the max temp file size to 0. Nginx by default will start to buffer on the disk. By setting it to 0 it will send it to the browser. The last piece of the puzzle I missed was turning gzip off, because it would try to buffer, even if it exceeded 1k, to compress the response. </p>
<p>Now, to get it to work, in my php script I echo out 1k worth of html commented out text to ensure everything else after it gets sent to the browser.</p>
<p>Now, I don&#8217;t recommend these settings for busy productions servers. However, only 3 people use this staff panel, so the performance differences are extremely low. </p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/06/23/php-practices-buffering-your-autoload/' rel='bookmark' title='PHP Practices: Buffering your autoload'>PHP Practices: Buffering your autoload</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/09/21/swiftmailer-sending-mail-in-php-with-ease/' rel='bookmark' title='SwiftMailer &#8211; Sending Mail in PHP With Ease'>SwiftMailer &#8211; Sending Mail in PHP With Ease</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/01/24/php-nginx-and-output-flushing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL Sleeping Connections &amp; PHP</title>
		<link>http://www.justincarmony.com/blog/2011/01/08/mysql-sleeping-connections-php/</link>
		<comments>http://www.justincarmony.com/blog/2011/01/08/mysql-sleeping-connections-php/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 20:51:48 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[jet profiler]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[optimizations]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[scaling]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=706</guid>
		<description><![CDATA[If you want to skip to the explanation, just read below. But before then, here is a little background. A Little Background On January 2nd, we started to run into some serious performance problems with Dating DNA, so we began the process of going and deciding what were our problems, and how to optimize them. ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/07/01/mysql-php-sql_calc_found_rows-an-easy-way-to-get-the-total-number-of-rows-regardless-of-limit/' rel='bookmark' title='MySQL &amp; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT'>MySQL &#038; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/03/mysql-does-table-exist-wo-throwing-errors/' rel='bookmark' title='MySQL &#8211; Does Table Exist w/o Throwing Errors'>MySQL &#8211; Does Table Exist w/o Throwing Errors</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/' rel='bookmark' title='MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes'>MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/mysql_logo.gif"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/mysql_logo.gif" alt="" title="mysql_logo" width="300" height="167" class="alignright size-full wp-image-710" /></a><strong>If you want to skip to the explanation, just read below. But before then, here is a little background.</strong></p>
<h2>A Little Background</h2>
<p>On January 2nd, we started to run into some serious performance problems with <a href="http://www.datingdna.com/">Dating DNA</a>, so we began the process of going and deciding what were our problems, and how to optimize them. At the beginning, the Database was the bottleneck. It would get flooded with requests, and unable to handle them all, each query would slow down. We were using a tool called <a href="http://www.jetprofiler.com/">Jet Profiler</a> (which I will post about more in detail later), but here is a graph it would output before we started out optimizations:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-JP-Jan1.gif"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-JP-Jan1.gif" alt="" title="DDNA-JP-Jan1" width="600" height="214" class="alignnone size-medium wp-image-707" /></a></p>
<p>The light blue is total threads connected. The dark blue is thread running a query. The red are threads that are taking 2 seconds or longer to run, which are slow queries. The red is bad, very bad. So we were getting in bad shape. It was lovingly nick named &#8220;The Red Zone&#8221; while we were working on optimizations. Now, granted, we weren&#8217;t in &#8220;The Red Zone&#8221; the whole time, but when things got busy, things would slow down.</p>
<p>But optimization after optimization, we started to get things more and more under control:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-JP-Chat2.gif"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-JP-Chat2.gif" alt="" title="DDNA-JP-Chat2" width="600" height="154" class="alignnone wp-image-714" /></a></p>
<p>After about three days of optimizations, we get back down to a manageable load:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-JP-PostOps.gif"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-JP-PostOps.gif" alt="" title="DDNA-JP-PostOps" width="364" height="331" class="alignnone size-full wp-image-716" /></a></p>
<h2>The Problem</h2>
<p>However, when the website was having high traffic, we noticed an anomaly, which looked like &#8220;blue waves.&#8221; We lovingly gave them the nickname of &#8220;<a href="http://www.youtube.com/watch?v=2AwvRzOh4RA">blue meanies</a>&#8221; from the Beatles&#8217; <a href="http://en.wikipedia.org/wiki/Yellow_Submarine_%28film%29">Yellow Submarine Cartoon</a>. On Jet Profiler, here is what it would report:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-BlueWaves.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-BlueWaves.png" alt="" title="DDNA-BlueWaves" width="600" height="184" class="alignnone wp-image-717" /></a></p>
<p>It would get worse and worse, these big blue waves of connections reporting as &#8220;sleeping.&#8221; At first we didn&#8217;t think it would be a problem. However, when ever we had &#8220;blue meanies&#8221; the site and iPhone app felt really slow. So, I won&#8217;t cover all the things I tested and tried that didn&#8217;t work, but he is ultimately how we figured out our problem.</p>
<h2>The Solution</h2>
<p>At first, I thought it was an issue with Garbage Collection with PHP. So I set the wait_timeout on MySQL to something really low, like 5 seconds. We then started to get errors all over the website, so we knew that they were legitimate connections from PHP. The only thing that made sense is that PHP &#038; Apache now had become the bottle neck, that MySQL was returning requests so quickly that the threads were almost always sleeping, waiting for the PHP to finish. We slowly started to disable different functions on the website, trying to narrow down if there was a particular part of the website that was causing it. After a few hours, we figured out the feature: the ChatWalls. So we started to investigate why turning off the ChatWalls would make MySQL run faster, since we had moved the ChatWalls completely off MySQL and to run on Redis.</p>
<p>What we found is one particular function had a typo, that would cause PHP to iterate over an array not 10 to 20 times, but 1,000-2,000 times or more. This function was also called <strong>a lot</strong> by several Ajax calls. So, I fixed the typo, and the blue waves went away. </p>
<p>What was happening is Apache &#038; PHP were spending so much time processing the buggy function, that it would cause the rest of the web requests to slow down greatly. That would keep open may too many MySQL connections, causing the blue ways, and slowing down the website even more.</p>
<p>So in reality, the blue waves were a symptom of the problem, not the cause. It is the whole <a href="http://en.wikipedia.org/wiki/Correlation_does_not_imply_causation">Correlation vs Causation</a> situation (which I probably should blog about in more detail when it comes to finding performance issues). </p>
<p>So if you have a lot of sleeping connections, but MySQL is performing well, most likely it is PHP or Apache slowing things down. I hope this can help those having a similar problem. As for our Database, its working well now. A few more problems to iron out, but it is running really fast. The few red spikes are from the score generation system that are doing bulk inserts, and do not slow down the end user experience:</p>
<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-FP-Today.gif"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2011/01/DDNA-FP-Today.gif" alt="" title="DDNA-FP-Today" width="600" height="274" class="alignnone wp-image-720" /></a></p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/07/01/mysql-php-sql_calc_found_rows-an-easy-way-to-get-the-total-number-of-rows-regardless-of-limit/' rel='bookmark' title='MySQL &amp; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT'>MySQL &#038; PHP  – SQL_CALC_FOUND_ROWS – An easy way to get the total number of rows regardless of LIMIT</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/03/mysql-does-table-exist-wo-throwing-errors/' rel='bookmark' title='MySQL &#8211; Does Table Exist w/o Throwing Errors'>MySQL &#8211; Does Table Exist w/o Throwing Errors</a></li>
<li><a href='http://www.justincarmony.com/blog/2009/01/12/mysql-40-million-rows-myisam-innodb/' rel='bookmark' title='MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes'>MySQL, 40 Million Rows, MyISAM to InnoDB, 45 Minutes</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2011/01/08/mysql-sleeping-connections-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN Switch &#8211; Key to Success In Web Development</title>
		<link>http://www.justincarmony.com/blog/2010/09/17/svn-switch-key-to-success-in-web-development/</link>
		<comments>http://www.justincarmony.com/blog/2010/09/17/svn-switch-key-to-success-in-web-development/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 08:13:05 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=625</guid>
		<description><![CDATA[So lately I have been given some thought to how we use Subversion (SVN) in our web development, and features we don&#8217;t use nearly as often. In web development, one big area where I don&#8217;t see us using a lot is branching, tagging, and merging. However, with our iPhone Apps, we use tagging and branching ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/09/24/zend-studio-vs-php-development-tools/' rel='bookmark' title='Zend Studio vs PHP Development Tools'>Zend Studio vs PHP Development Tools</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/13/speaking-utah-php-usergroup-streamlined-web-development/' rel='bookmark' title='Speaking: Utah PHP Usergroup – Streamlined Web Development'>Speaking: Utah PHP Usergroup – Streamlined Web Development</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/20/streamlined-web-development-in-depth/' rel='bookmark' title='Streamlined Web Development: In-Depth'>Streamlined Web Development: In-Depth</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/09/subversion_logo-384x332.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2010/09/subversion_logo-384x332-300x259.png" alt="" title="subversion_logo-384x332" width="300" height="259" class="alignright size-medium wp-image-626" /></a>So lately I have been given some thought to how we use <a href="http://subversion.tigris.org/">Subversion</a> (SVN) in our web development, and features we don&#8217;t use nearly as often.</p>
<p>In web development, one big area where I don&#8217;t see us using a lot is branching, tagging, and merging. However, with our iPhone Apps, we use tagging and branching <strong><em>a lot</em></strong>. As I started to think why, one of the biggest things was the <strong>environment</strong>. Client development, especially with the iPhone, is double clicking on a project file for Xcode, and I&#8217;m ready to go. There is almost no hassle running trunk versus running a tag or branch. It is all the same.</p>
<p>Building against a website, however, is different. Your environment requires a lot more information and pieces. For me, I need to make changes to my host file (for custom domains), Apache/Nginx configuration, MySQL Connection information, etc. There is no file i &#8220;double click&#8221; and go. It is a pain anytime I need to change my local (or staging or even production) paths and settings.</p>
<p>This is where the <a href="http://svnbook.red-bean.com/en/1.0/ch04s05.html">svn switch</a> command comes in handy, and is extremely important. It allows you to change your checked out working copy&#8217;s source (or url), while maintaining any local changes you may have made. You can tell the actual path, regardless of file or directory names, by doing an svn info command. The best way to understand is through examples.</p>
<h3>Arg, should have made this a branch.</h3>
<p>You&#8217;re working on a big change, such as completely rewriting your internal message system. Suddenly, your boss walks in saying &#8220;There is a bug we need you to fix and push live now!&#8221; It is a simple bug, but your trunk is only half way through a major change. What do you do?</p>
<ol>
<li><strong>New Branch on Server</strong> &#8211; You need to make a new branch on the server based off the server&#8217;s version of trunk. It&#8217;s a simple copy function, while having it execute on the server:
<p>svn copy -m &#8220;Branching for new email system&#8221; http://svn.example.com/trunk/ http://svn.example.com/branches/new_email_system/</li>
<li><strong>Switch your trunk working copy to new branch</strong> &#8211; This allows you to keep all of your current changes locally, but switches you to the branch version:
<p>cd /path/to/trunk/ <br />svn switch http://svn.example.com/branches/new_email_system/</li>
<li><strong>Commit changes to branch</strong> &#8211; Commit your changes to the repository which will be applied to the branch:
<p>svn commit -m &#8220;changes to new message system.&#8221;</li>
<li><strong>Switch back to trunk.</strong> &#8211; Make sure you are still at your trunk. If you did an svn info, it would show the URL location at the branch. Execute the switch again:
<p>svn switch http://svn.example.com/trunk/</li>
<li><strong>Switch between trunk &#038; branch as needed</strong> &#8211; When you need to work on the trunk, switch to the trunk. When you need to work on the branch, switch to the branch. The great thing is you won&#8217;t need to change any URLs in your configs in apache and such, it will just work. </li>
<li><strong>When your branch is ready, merge into trunk</strong> &#8211; Perform a merge since the starting of the branch to the last revision in the branch, applying it to the trunk:
<p>svn merge -r 100:125 path/to/branches/new_email_system path/to/trunk</li>
<li><strong>Test changes made by merge, then commit.</strong> &#8211; Test the changes locally, and when you are satisfied things went well, commit the merged changes to trunk: svn commit -m &#8220;new message&#8221;
<li><strong>Continue Development</strong> &#8211; you are safe to proceed as usual.</li>
</ol>
<p>Over the new few weeks I plan on posting more little tutorials and tricks of some more advanved SVN commands, and hopefully it can help some of my fellow team members. Let me know if you have any questions, or want to know how to do other things. But the bottom line is if you haven&#8217;t used the svn switch command, especially in web development, you are sorely missing out.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/09/24/zend-studio-vs-php-development-tools/' rel='bookmark' title='Zend Studio vs PHP Development Tools'>Zend Studio vs PHP Development Tools</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/13/speaking-utah-php-usergroup-streamlined-web-development/' rel='bookmark' title='Speaking: Utah PHP Usergroup – Streamlined Web Development'>Speaking: Utah PHP Usergroup – Streamlined Web Development</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/11/20/streamlined-web-development-in-depth/' rel='bookmark' title='Streamlined Web Development: In-Depth'>Streamlined Web Development: In-Depth</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2010/09/17/svn-switch-key-to-success-in-web-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XAMPP for Mac &#8211; My Frustrations &amp; Solutions</title>
		<link>http://www.justincarmony.com/blog/2009/02/14/xampp-for-mac-my-frustrations-solutions/</link>
		<comments>http://www.justincarmony.com/blog/2009/02/14/xampp-for-mac-my-frustrations-solutions/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 23:15:34 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacBook Pro]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=396</guid>
		<description><![CDATA[These last few days I&#8217;ve been trying to get XAMPP to work on my MacBook Pro these last couple of days and it has been frustrating! It seemed I kept running into more and more problems. For those who don&#8217;t know, XAMPP is tool for developers to run a LAMP stack (Linux, Apache, MySQL, PHP) ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/10/14/php-video-tutorial-getting-started-installing-xampp/' rel='bookmark' title='PHP Video Tutorial – Getting Started – Installing XAMPP'>PHP Video Tutorial – Getting Started – Installing XAMPP</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/02/12/pagefindcontrol-returning-null-issues-and-solutions-within-another-control/' rel='bookmark' title='Page.FindControl() Returning Null Issues and Solutions Within Another Control'>Page.FindControl() Returning Null Issues and Solutions Within Another Control</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2009/02/xampp-objectdock.png"><img src="http://c747925.r25.cf2.rackcdn.com/blog/wp-content/uploads/2009/02/xampp-objectdock.png" alt="" title="xampp-objectdock" width="256" height="256" class="alignright size-full wp-image-633" /></a>These last few days I&#8217;ve been trying to get <a href="http://www.apachefriends.org/en/xampp.html" target="_blank">XAMPP</a> to work on my MacBook Pro these last couple of days and it has been <em><strong>frustrating</strong></em>! It seemed I kept running into more and more problems. For those who don&#8217;t know, XAMPP is tool for developers to run a LAMP stack (Linux, Apache, MySQL, PHP) on your machine locally. I&#8217;ve been running it on my Windows machines for years, and I have been running my production servers on Linux.</p>
<p>Installing just XAMPP and getting it to run with the Control Panel was easy. All my headaches started when I tried to get my vhosts installed and working. The problem I ran into getting XAMPP to run on my MacBook Pro were the following:</p>
<ol>
<li><strong>XAMPP for Mac is different from XAMPP for Windows</strong></li>
<li><strong>Max OS X comes with a Version of Apache Installed<br />
</strong></li>
<li><strong>Mac OS X has additional permissions that are different from Linux</strong></li>
</ol>
<h2>XAMPP for Mac != XAMPP for Windows</h2>
<p>My first mistake was that I assumed that XAMPP for Mac is the same as XAMPP for Windows. After digging into it, the file structure and config files are pretty different. The php.ini file is different, and all the binary files are in /xampp/xamppfiles/bin/. On windows the binary files are in their own folders. It took me awhile to figure out where everything was at. This led me into my next problem:</p>
<h2>Mac OS X comes with a Version of Apache Installed</h2>
<p>When I was trying to debug why stuff wasn&#8217;t working, I opened up the terminal and started running commands. There is just one problem, OS X already has a version of Apache installed. So when I cd&#8217;d into the bin directory, I would execute this command:</p>
<blockquote><p>apachectrl -t -D DUMP_VHOSTS</p></blockquote>
<p>There was just one problem, it was executing the apachectl that was installed by Mac OS X, not the one for XAMPP. So it all my debugging with the config files, etc. wasn&#8217;t working. I was going insane. Finally I figured out what was going on and I had to execute this command instead:</p>
<blockquote><p>./apachectl -t -D DUMP_VHOSTS</p></blockquote>
<p>It started behaving like I expected! This lead my to my third hang up.</p>
<h2>Mac OS X has additional permissions that are different from Linux</h2>
<p>This threw me for a loop to. I don&#8217;t understand exactly why this was happening, but I kept gettinga  Permission Denied when trying to view the vhost I was trying to setup. The way I used to do it on Windows is I have a partition for all of my development files. I would have a folder at the root of that drive called SVN_Repositories that holds all the SVN Repositories I use for work. So on my MacBook Pro at / I did the same, I had my SVN_Repositories folder. So my vhost would point to a directory like with a name something like this: &#8220;/SVN_Repositories/ExampleRepo/trunk/httpdocs/&#8221;</p>
<p>So my linux side clicked in and thought &#8220;Hrm, it looks like there is something wrong with the permissions. Let me change the folder permissions to 777 just to test.&#8221; So I did that and it still didn&#8217;t work. This it made me think it still was a vhost configuration issue. So I spent hours testing all sorts of stuff and just getting more frustrating. Then I read somewhere that XAMPP can have problems with OS X&#8217;s unique permissions on addition to the FreeBSD stuff it does. It said to host the vhost content in either the Applications folder or Users folder. So I moved my SVN_Repositories folder to my Users folder so it was like this: &#8220;/Users/<em>username</em>/SVN_Repositories/ExampleRepo/trunk/httpdocs/&#8221;</p>
<p>It finally worked! So the lessons I learned were:</p>
<ul>
<li>Put your vhost content in the Users folder.</li>
<li>If you try things from the terminal, make sure you do ./apachectl so you execute the correct binary file.</li>
<li>Most of your config files are in the /Applications/xampp/etc/ folder.</li>
</ul>
<p>As always, hopefully this helps someone. Feel free to leave any questions or comments.</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/10/14/php-video-tutorial-getting-started-installing-xampp/' rel='bookmark' title='PHP Video Tutorial – Getting Started – Installing XAMPP'>PHP Video Tutorial – Getting Started – Installing XAMPP</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/02/12/pagefindcontrol-returning-null-issues-and-solutions-within-another-control/' rel='bookmark' title='Page.FindControl() Returning Null Issues and Solutions Within Another Control'>Page.FindControl() Returning Null Issues and Solutions Within Another Control</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/' rel='bookmark' title='Local LAMP Developement &amp; User Content'>Local LAMP Developement &#038; User Content</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2009/02/14/xampp-for-mac-my-frustrations-solutions/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Local LAMP Developement &amp; User Content</title>
		<link>http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/</link>
		<comments>http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 20:37:26 +0000</pubDate>
		<dc:creator>Justin Carmony</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://www.justincarmony.com/blog/?p=213</guid>
		<description><![CDATA[I&#8217;ve come up with a simple solution for handling user uploaded content when trying to work in a local development environment. I&#8217;ve installed XAMPP on my windows machine and at the beginning of every week I take a database snapshot and update my local database. I had a pretty smooth system going with one problem: ...


Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/01/31/asp-net-systemthreadingthreadabortexception-error/' rel='bookmark' title='ASP .NET &amp; System.Threading.ThreadAbortException Error'>ASP .NET &#038; System.Threading.ThreadAbortException Error</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/06/17/os-x-and-tabs-skipping-drop-down-controls/' rel='bookmark' title='OS X and Tabs &#8211; Skipping Drop Down Controls'>OS X and Tabs &#8211; Skipping Drop Down Controls</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve come up with a simple solution for handling user uploaded content when trying to work in a local development environment. I&#8217;ve installed XAMPP on my windows machine and at the beginning of every week I take a database snapshot and update my local database. I had a pretty smooth system going with one problem: user uploaded content.</p>
<p>When working with social networking sites, many times they allow for users to upload their own videos, pictures, etc. My current project wasn&#8217;t different, but I didn&#8217;t want to download 80GB of user content every week to store on my PC. I wanted a way to point my browser to the live server to get recent images, etc.</p>
<p>My solution was simple: .htaccess file using a 301 redirect. I basically told my local apache server to return a HTTP status of 301 (Moved Permanently) and point the browser to the live content. I created a .htaccess file inside the &#8220;uploads&#8221; directory and added one line of code:</p>
<code class="code">Redirect 301 /uploads http://www.example.com/uploads</code>
<p>I restarted apache and now when I work locally, I can still see all of the user&#8217;s photos and uploaded content. Works like a champ!</p>


<p>Related posts:<ol><li><a href='http://www.justincarmony.com/blog/2008/01/31/asp-net-systemthreadingthreadabortexception-error/' rel='bookmark' title='ASP .NET &amp; System.Threading.ThreadAbortException Error'>ASP .NET &#038; System.Threading.ThreadAbortException Error</a></li>
<li><a href='http://www.justincarmony.com/blog/2008/06/17/os-x-and-tabs-skipping-drop-down-controls/' rel='bookmark' title='OS X and Tabs &#8211; Skipping Drop Down Controls'>OS X and Tabs &#8211; Skipping Drop Down Controls</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.justincarmony.com/blog/2008/10/10/local-lamp-developement-user-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 30/78 queries in 0.032 seconds using memcached
Content Delivery Network via Rackspace Cloud Files: c747925.r25.cf2.rackcdn.com

Served from: www.justincarmony.com @ 2012-02-07 20:49:50 -->
