<?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>Chris Gilligan » new mediaDatabase » Chris Gilligan » new media »</title> <atom:link href="http://chrisgilligan.com/tag/database/feed/" rel="self" type="application/rss+xml" /><link>http://chrisgilligan.com</link> <description>portfolio of web work</description> <lastBuildDate>Sun, 05 Feb 2012 16:30:37 +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>How to Configure APC Cache on Virtual Servers with PHP running under FCGId</title><link>http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/</link> <comments>http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/#comments</comments> <pubDate>Tue, 09 Nov 2010 01:33:31 +0000</pubDate> <dc:creator>Chris Gilligan</dc:creator> <category><![CDATA[Wordpress]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[apc]]></category> <category><![CDATA[apc cache]]></category> <category><![CDATA[apc fcgid]]></category> <category><![CDATA[commodity web]]></category> <category><![CDATA[Database]]></category> <category><![CDATA[hooks]]></category> <category><![CDATA[hosts section]]></category> <category><![CDATA[ini]]></category> <category><![CDATA[installation suggestions]]></category> <category><![CDATA[memory limit]]></category> <category><![CDATA[mpm]]></category> <category><![CDATA[page cache]]></category> <category><![CDATA[performance testing]]></category> <category><![CDATA[php module]]></category> <category><![CDATA[php.ini apc settings]]></category> <category><![CDATA[server performance]]></category> <category><![CDATA[system resources]]></category> <category><![CDATA[traffic surges]]></category> <category><![CDATA[virtual domains]]></category> <category><![CDATA[virtual hosts]]></category> <category><![CDATA[virtual private server]]></category> <category><![CDATA[virtual servers]]></category> <category><![CDATA[virtualmin]]></category> <category><![CDATA[web hosting servers]]></category><guid
isPermaLink="false">http://chrisgilligan.com/?p=274</guid> <description><![CDATA[My Virtualmin CentOS 5.6 Virtual Private Server runs several virtual domains with PHP under FCGId using APC for opcode caching: Joomla, PHPbb, WordPress, etc . APC is somewhat challenging to configure properly with fcgid-enabled virtual domains, but it is quite helpful to optimize system resources and prevent traffic surges on one site from affecting overall [...]]]></description> <content:encoded><![CDATA[<p
style="float:right; margin:0 0 10px 15px; width:240px;"> <img
src="http://chrisgilligan.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-6.20.12-PM.png" width="240" /></p><div
id="attachment_306" class="wp-caption alignright" style="width: 301px"><a
href="http://chrisgilligan.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-6.20.12-PM.png"><img
class="size-medium wp-image-306" title="APC INFO" src="http://chrisgilligan.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-6.20.12-PM-291x300.png" alt="APC INFO Monitor" width="291" height="300" /></a><p
class="wp-caption-text">APC INFO Monitor</p></div><p><strong>My Virtualmin CentOS 5.6</strong> Virtual Private Server runs several virtual domains with <strong>PHP under FCGId</strong> using <strong>APC for opcode caching</strong>: Joomla, PHPbb, WordPress, etc . APC is somewhat challenging to configure properly with fcgid-enabled virtual domains, but it is quite helpful to optimize system resources and prevent traffic surges on one site from affecting overall server performance. Joomla and PHPbb have code that is pre-optimized with hooks for APC, but WordPress requires a plugin called <strong>W3 Total Cache</strong>.</p><h3>First Things First</h3><p>Please read my posts about <a
title="APC Cache Considerations for Virtual Hosting Environments" href="http://chrisgilligan.com/wordpress/apc-cache-considerations-for-virtual-hosting-environments/">APC on commodity virtual hosting servers</a> and <a
title="Tuning Apache and MySQL for Best Performance in a Shared Virtual Hosting Environment" href="http://chrisgilligan.com/portfolio/tuning-apache-and-mysql-for-best-performance-in-a-shared-virtual-hosting-environment/">Apache and MySQL performance tuning</a> before you begin.</p><p>If you are running your virtual servers under FCGId, then you should do so for all virtual servers on your machine. Why? Because then you do not need apache&#8217;s mod_php (php module). Less modules loaded, less wasted memory.</p><ul><li>Comment out:<code><br
/> LoadModule php5_module modules/libphp5.so</code><br
/> in /etc/httpd/conf.d/php.conf</li><li>Remove any php_memory_limit lines in httpd.conf&#8217;s virtual hosts section.<code></code></li><li>restart apache<br
/> <code></code></li><li>do some performance testing and raise your server and thread limits to sane levels in httpd.conf</li></ul><p>If possible, you may wish to run Apache with Worker MPM instead of Prefork MPM.</p><ul><li>More information about <a
title="Apache config for Worker MPM vs Prefork MPM" href="http://chrisgilligan.com/wordpress/apache-config-for-worker-mpm-vs-prefork-mpm/">Apache Worker MPM vs. Prefork MPM »</a></li></ul><p><span
class="Apple-style-span" style="font-size: 15px; font-weight: bold;">Installation Suggestions and Modification of Defaults</span></p><p>Be sure to install the newest version of APC, 3.1.9 as of the last revision of this post (I assume you know how to install and configure all the packages mentioned in this post):</p><p><code>pecl install apc</code></p><p><strong>For W3 Total Cache (WordPress plugin):</strong><br
/> Page Cache: do not choose APC for the W3TC&#8217;s Page Cache, choose Enhanced Disk.<br
/> Minify: do not choose APC for Minify, use Disk.<br
/> Opcode Cache: choose APC for Opcode Cache<br
/> Database Cache: choose APC for Opcode Cache<em><br
/> </em></p><p><strong>For APC running on virtual servers for opcode caching:</strong><br
/> <em> Remove</em> apc.ini from /etc/php.d. Do not add the APC configuration into /etc/php.ini (main php.ini which is probably a template used for creation of new virtual servers).</p><p>Instead, enable APC on a per-domain basis by modifying the respective /home/domainname.com/etc/php5/php.ini &#8212; your httpd.conf or virtual.conf should look something like this for each virtual domain.</p><p><code>&lt;VirtualHost 99.88.177.288:80&gt;<br
/> ServerName chrisgilligan.com<br
/> ServerAlias www.chrisgilligan.com<br
/> DocumentRoot /home/chris/public_html<br
/> ErrorLog /var/log/serversoftware/chrisgilligan.com_error_log<br
/> CustomLog /var/log/serversoftware/chrisgilligan.com_access_log combined<br
/> ScriptAlias /cgi-bin/ /home/chris/cgi-bin/<br
/> DirectoryIndex index.html index.htm index.php index.php4 index.php5<br
/> &lt;Directory /home/chris/public_html&gt;<br
/> Options Indexes IncludesNOEXEC FollowSymLinks ExecCGI<br
/> allow from all<br
/> AllowOverride All<br
/> AddHandler fcgid-script .php<br
/> AddHandler fcgid-script .php5<br
/> FCGIWrapper /home/chris/fcgi-bin/php5.fcgi .php<br
/> FCGIWrapper /home/chris/fcgi-bin/php5.fcgi .php5<br
/> &lt;/Directory&gt;<br
/> &lt;Directory /home/chris/cgi-bin&gt;<br
/> allow from all<br
/> &lt;/Directory&gt;<br
/> SuexecUserGroup "#987" "#756"<br
/> Options ExecCGI FollowSymLinks Includes IncludesNOEXEC -Indexes MultiViews SymLinksIfOwnerMatch<br
/> RemoveHandler .php<br
/> RemoveHandler .php5<br
/> IPCCommTimeout 12<br
/> &lt;/VirtualHost&gt;<br
/> </code></p><p>You must &#8220;babysit&#8221; the configuration: use the APC monitor (apc.php) to see how many files are being cached, and how much memory (apc.shm_size) is needed to avoid fragmentation, which will cause the 500 errors. If fragmentation rises quickly to 100%, memory usage is full, and cache full count rises above 0, you will almost surely see &#8220;500&#8243; errors.</p><p>If WordPress is the only PHP script software package on the domain, the following configuration will likely work for you; if you have more PHP software packages, you will need to raise apc.shm_size and raise the apc.user_entries_hint and apc.user_entries_hint settings, and possibly lower TTL values to allow cached files to expire and be replaced.</p><p>In general, you must <em>double</em> apc.shm_size in relation to APC&#8217;s highest reported Memory Usage to avoid fragmentation completely.</p><h3>Configuration Suggestion for php.ini</h3><p>in the virtual server&#8217;s /home/domainname.com/etc/php5/php.ini, add the following configuration:<br
/> (you may also install memcached, and should install fileinfo for full use of W3 Total Cache)</p><p><code>[memcached]<br
/> ;memcached for distributed servers - e.g. mysql server on separate host<br
/> ;extension=memcache.so</code></p><p><code>[fileinfo]<br
/> extension=fileinfo.so</code></p><p><code>[APC]<br
/> extension = apc.so<br
/> apc.enabled = 1<br
/> apc.shm_segments = 1<br
/> apc.shm_size = 32M<br
/> apc.optimization = 0<br
/> apc.num_files_hint = 512<br
/> apc.user_entries_hint = 1024<br
/> apc.ttl = 0<br
/> apc.user_ttl = 0<br
/> apc.gc_ttl = 600<br
/> apc.cache_by_default = 1<br
/> apc.filters = "apc\.php$"<br
/> apc.slam_defense = 0<br
/> apc.use_request_time = 1<br
/> apc.mmap_file_mask = /tmp/apc-yourusernamehere.XXXXXX<br
/> ;OR apc.mmap_file_mask = /dev/zero<br
/> apc.file_update_protection = 2<br
/> apc.enable_cli = 0<br
/> apc.max_file_size = 2M<br
/> apc.stat = 1<br
/> apc.write_lock = 1<br
/> apc.report_autofilter = 0<br
/> apc.include_once_override = 0<br
/> apc.rfc1867 = 0<br
/> apc.rfc1867_prefix = "upload_"<br
/> apc.rfc1867_name = "APC_UPLOAD_PROGRESS"<br
/> apc.rfc1867_freq = 0<br
/> apc.localcache = 1<br
/> apc.localcache.size = 512<br
/> apc.coredump_unmap = 0<br
/> apc.stat_ctime = 0</code></p><p>Save php.ini, restart apache and then watch the APC Monitor to ensure fragmentation stays below 50% (it should remain less than 10% most of the time&#8230; if fragmentation rises quickly, you should add a few more MB&#8217;s of memory to apc.shm_size and restart apache).</p><h3>Monitoring APC Performance and Detecting Errors</h3><p>You should run apc.php in a password-protected directory in the domain&#8217;s public_html. Edit the apc.php code to allow passwordless access.<br
/> <code>defaults('USE_AUTHENTICATION',0);</code></p><p>You can monitor errors with these commands:<br
/> <code>tail -f -n 50 /var/log/httpd/error_log<br
/> tail -f -n 50 /home/domainname.com/logs/error_log</code></p><p>In the logs, you should see messages like the following:<br
/> <code>mod_fcgid: process /home/username/public_html/scriptname.php(21272) exit(lifetime expired), terminated by calling exit(), return code: 0</code><br
/> <code>... exit(server exited) ...</code><br
/> <code>... exit(idle timeout) ...</code><br
/> if the cache is working well. If you see <code>exit(communication error)</code> then you have issues, probably cache full and fragmented.</p><h3>Fragmentation Explained</h3><p>Fragmentation is a measure of the non-available portion of apc.shm_size due to lack of contiguous memory large enough to accept new cache items. 100% fragmentation means the available memory is broken into hundreds of small pieces that are too small to accept new cache items. This occurs when cached items expire and new cached items fill their vacated memory slots; usually the new item is slightly smaller than the old item, and the leftover space may be too small for a new cache item.</p><p>Fragmentation can cause even a large amount of free memory to be unavailable for new cache items. That is why I say above you can avoid fragmentation by doubling the apc.shm_size in relation to the largest total memory usage you see. So you may want to start with 100MB, let the site run for a few hours during high traffic conditions, and then reduce shm_size to roughly double the highest amount of cache memory usage during that time.</p><h3>Further Information and Suggestions</h3><p>APC can have a very significant effect on minimizing overall server load and overall memory usage. It takes time to configure, and must be re-configured whenever PHP script software is added to a virtual server. The more plugins/mods/components you add to a PHP software package, the more scripts, database queries and objects will be cached.</p><p>If you have PHP scripts or plugins that do not need to be cached (low traffic pages such as contact forms, PHP scripts that do not have APC hooks and have their own caching schemes, dynamic image resizers, etc.), you can filter them out with simple RegEx:<br
/> <code>apc.filters = "-/home/username/public_html/apc\.php$,-/home/username/public_html/wordpress/wp-content/themes/themename/thumb\.php$,-/usr/share/psa-horde/.*,+/home/username/public_html/phpmyadmin/.*"</code></p><p>TimThumb is a good example of a common WordPress theme plugin that may not need to be cached.</p><p>Because the apc.filters RegExp only works with filenames, it is not possible to filter out an entire PHP script package, component or plugin based on the directory where it resides. So if you do not wish to use APC cache on a particular script package, you should run it in a separate website. Some PHP script packages such as Gallery2 have an incredibly large number of .php, .inc and .class files which will be cached, so it is difficult to find them all and filter them all using apc.filters.</p><p>If you can&#8217;t raise apc.shm_size due to lack of available memory, try lowering the TTL&#8217;s (values in seconds, 0 is no limit, 600=10minutes, etc.). This will still have a good effect on high-traffic sites with many concurrent end users; caching is not at all necessary for low-traffic sites. However, be aware that lower TTL&#8217;s can cause more fragmentation.</p><h3>During Testing or Debugging with CMS caching plugins or modules</h3><p>While you are tweaking your opcode settings, and especially if you are using APC with a CMS like WordPress (w3 total cache) or phpbb or joomla, and you are experimenting with settings, you should set apc.stat=1 (on). Restart the web server to load the new settings.</p><p>APC.Stat is the file change polling, which checks for file change every time a cached script or object is called. So, with polling turned off, your settings/configuration files may remain cached, and this may cause you some frustration. W3 Total Cache in particular is difficult to get configured properly with apc.stat=0 because the config settings and files are dependent upon database and php, which will be cached as files or opcode.</p><p>After you have sorted out your opcode settings, switch apc.stat=0 and restart the web server to turn off polling for better performance.</p><p>If you cannot get APC to configured correctly for your WordPress sites, I suggest WP Super Cache and WP Minify&#8230; that combination will probably have a better effect, as it will serve pages very quickly and accellerate user experience for a small number of users. Joomla 1.5 and phpBB3 are much easier to work with, as their caching systems are built to use APC and other opcode caches. Apparently, Gallery3 now also supports opcode caching.</p><p><strong>More advice: </strong></p><ul><li>turn <strong><em>on</em></strong> apc.stat (documentation says, not for production servers, but W3 needs stat to monitor file status)</li><li>turn <strong><em>off</em></strong> apc.optimization (experimental and unstable, may cache user session info, fubaring items which should not be cached, such as admin pages and logged-in site pages)</li><li>turn <strong><em>off</em></strong> apc.include_once_override (use carefully; only useful with PHP scripts that do not have cache hooks, such as Joomla 1.0, phpBB2, etc.)</li><li>turn <em><strong>off</strong></em> apc.slam_defense (may cause objects to be replaced with PHP warnings which are displayed to the user, especially on Joomla 1.5)</li><li>set apc.user_ttl = 0 (allows your php scripts to set appropriate timeouts for queries and objects)</li><li>set apc.mmap_file_mask = /tmp/apc-yourusernamehere.XXXXXX for file-backed mmap; make file mask unique by adding your unique string; XXXXXX (exactly 6 X&#8217;s) must remain to allow APC to add random string<br
/> OR set to /dev/zero for anonymous mmap if you can spare the memory</li></ul><p><small>APC Manual: <a
href="http://www.php.net/manual/en/book.apc.php">http://www.php.net/manual/en/book.apc.php</a><br
/> APC Runtime Configuration <a
href="http://www.php.net/manual/en/apc.configuration.php">http://www.php.net/manual/en/apc.configuration.php</a></small></p> <strong
class="seo-searchterms">Incoming search terms for the article:</strong><ul
class="seo-searchterms"><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="configure APC">configure APC</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="For optimal performance we recommend adding the Alternative PHP Cache (APC) extension">For optimal performance we recommend adding the Alternative PHP Cache (APC) extension</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="apc config">apc config</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="[ phpinfo ] [ php ini ] [ cpu ] [ mem ] [ users ] [ tmp ] [ delete ]">[ phpinfo ] [ php ini ] [ cpu ] [ mem ] [ users ] [ tmp ] [ delete ]</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="apc user cache entries timeout">apc user cache entries timeout</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="how to configure apc">how to configure apc</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="howto config apc so">howto config apc so</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="apc fragmentation">apc fragmentation</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="php apc config">php apc config</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/" title="apache is running a threaded mpm but your php module is not compiled to be threadsafe">apache is running a threaded mpm but your php module is not compiled to be threadsafe</a></li></ul>]]></content:encoded> <wfw:commentRss>http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/feed/</wfw:commentRss> <slash:comments>41</slash:comments> </item> <item><title>Art Competition with Submission Form</title><link>http://chrisgilligan.com/portfolio/art-competition-with-submission-form/</link> <comments>http://chrisgilligan.com/portfolio/art-competition-with-submission-form/#comments</comments> <pubDate>Thu, 02 Apr 2009 22:03:54 +0000</pubDate> <dc:creator>Chris Gilligan</dc:creator> <category><![CDATA[Arts and Nonprofit]]></category> <category><![CDATA[Portfolio]]></category> <category><![CDATA[Database]]></category> <category><![CDATA[Forms]]></category> <category><![CDATA[Wordpress]]></category><guid
isPermaLink="false">http://chrisgilligan.com/?p=98</guid> <description><![CDATA[This is a project for Create Here, a Chattanooga think tank nonprofit that connects entrepreneurs and artists with creative communicators to promote sustainable, creative initiatives and showcases. Zero Sum is an exhibit that examines the role of games in contemporary culture and the impact they have on our social experience, psyche, morality and approach to [...]]]></description> <content:encoded><![CDATA[<p
style="float:right; margin:0 0 10px 15px; width:240px;"> <img
src="http://chrisgilligan.com/wp-content/uploads/2009/04/picture-2.png" width="240" /></p><div
id="attachment_99" class="wp-caption alignright" style="width: 310px"><a
href="http://zerosumshow.com/submit/"><img
class="size-medium wp-image-99" title="picture-2" src="http://chrisgilligan.com/wp-content/uploads/2009/04/picture-2-300x222.png" alt="Zero Sum Website" width="300" height="222" /></a><p
class="wp-caption-text">Zero Sum Website</p></div><p>This is a project for <a
href="http://createhere.org/">Create Here, a Chattanooga think tank nonprofit</a> that connects entrepreneurs and artists with creative communicators to promote sustainable, creative initiatives and showcases. Zero Sum is an exhibit that examines the role of games in contemporary culture and the impact they have on our social experience, psyche, morality and approach to critical thinking.</p><ul><li>Online forms for artistic submissions</li><li>Database to collect and organize submissions, including file uploads</li><li>Search Engine Optimization, sitemaps, Google Analytics to provide info about traffic and visitors</li></ul> <strong
class="seo-searchterms">Incoming search terms for the article:</strong><ul
class="seo-searchterms"><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/portfolio/art-competition-with-submission-form/" title="games powered by expressionengine">games powered by expressionengine</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/portfolio/art-competition-with-submission-form/" title="intext:powered by expressionengine games">intext:powered by expressionengine games</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/portfolio/art-competition-with-submission-form/" title="powered by expressionengine gaming">powered by expressionengine gaming</a></li><li
class="seo-searchterms"><a
href="http://chrisgilligan.com/portfolio/art-competition-with-submission-form/" title="powered by phpBB cabinets">powered by phpBB cabinets</a></li></ul>]]></content:encoded> <wfw:commentRss>http://chrisgilligan.com/portfolio/art-competition-with-submission-form/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Served from: chrisgilligan.com @ 2012-02-06 10:18:31 by W3 Total Cache -->
