Using .htaccess to Report Delivery Time

Link: http://httpd.apache.org/docs/2.2/mod/mod_headers.html

The question was whether the number of rewrite rules in .htaccess would have a significant impact on performance.

With the following set of rewrite rules:

Code:

Options +FollowSymLinks -Indexes
<IfModule mod_php5.c>
        php_value magic_quotes_gpc 0
        php_value magic_quotes_runtime 0
        php_value allow_call_time_pass_reference 0
</IfModule>
DirectoryIndex index.php
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^cms/index\.php/plain_admin$ http://domain.com/admin [R=3
01,L]
        RewriteRule ^cms/index\.php/plain(.*) $1 [R=301,L]
        RewriteRule ^media.* - [L]
        RewriteRule ^custom.* - [L]
        RewriteRule content/treemenu/? /index_treemenu.php [L]
        RewriteRule ^var/[^/]+/cache/public/.* - [L]
        RewriteRule ^var/storage/.* - [L]
        RewriteRule ^var/[^/]+/storage/.* - [L]
        RewriteRule ^var/cache/texttoimage/.* - [L]
        RewriteRule ^var/[^/]+/cache/texttoimage/.* - [L]
        RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
        RewriteRule ^share/icons/.* - [L]
        RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]
        RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
        RewriteRule ^packages/styles/.+/thumbnail/.* - [L]
        RewriteRule ^/favicon\.ico - [L]
        RewriteRule ^/robots\.txt - [L]
        # Uncomment the following lines when using popup style debug.
        # RewriteRule ^/var/cache/debug\.html.* - [L]
        # RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L]
 
        RewriteCond %{HTTP_HOST} ^webdav\..*
        RewriteRule ^(.*) /webdav.php [L]
 
        RewriteRule .* index.php
</IfModule>

The results were:

Received: t=1267660375832889 Duration: D=273652
Received: t=1267660761803171 Duration: D=297682
Received: t=1267660779066518 Duration: D=272959
Received: t=1267660804103095 Duration: D=292675
Received: t=1267660821137470 Duration: D=256268

This set of rewrite rules:

Code:

Options +FollowSymLinks -Indexes
<IfModule mod_php5.c>
        php_value magic_quotes_gpc 0
        php_value magic_quotes_runtime 0
        php_value allow_call_time_pass_reference 0
</IfModule>
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^media.* - [L]
RewriteRule ^custom.* - [L]
RewriteRule !(\.(gif|jpe?g?|png|css|swf|mp4|js|html?)|var(.+)storage.pdf(.+)\.pdf)$ index.php
</IfModule>

Yielded these results:

Received: t=1267660624947466 Duration: D=279933
Received: t=1267660660237894 Duration: D=289207
Received: t=1267660681578539 Duration: D=327192
Received: t=1267660701894745 Duration: D=254252
Received: t=1267660719493366 Duration: D=262131

This was a very informal test, just to see if there were any glaring differences, as you can see, the results were reasonably close.

Shared Hosting - In a pinch permission updates

Link: http://www.php.net/manual/en/function.chmod.php

After a long day working on an upgrade, I realized I needed to adjust the permissions of directories and files that were owned by nobody.nobody.

I was about to send a ticket to the hosting company, when I realized you can use PHP to change the permissions, and invoke the script through the browser.

It wasn’t graceful, or efficient, but, it did let me change permissions and continue.

The real lesson is to wait until the last minute to ask the hosting company to change ownership of the files. I hurried, because the server was hacked when I logged in.

Apache configuration for a simple development server

Link: http://httpd.apache.org/docs/2.2/vhosts/examples.html#purename

I’m setting up a CentOS 5.4 laptop to build a new site for St. Kathryn’s Church in Hudson, NH (http://stkathryns.org).

I want to use the server to run other sites as well, so setting up virtual hosts was one of the first steps.

I like to use a dedicated /etc/httpd/conf.d/vhost.conf file for settings that affect all sites on the server.

/etc/httpd/conf.d/vhost.conf

Code:

ServerName 127.0.0.1
NameVirtualHost *:80

/etc/httpd/conf.d/localhost.conf has the localhost settings.

Code:

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName 127.0.0.1
ServerAlias localhost
</VirtualHost>

/etc/httpd/conf.d/stkathryns.conf has the settings for St. Kathryn’s new site.

Code:

<VirtualHost *:80>
DocumentRoot /var/www/html/stk
ServerName stkathryns.org
ServerAlias stk
</VirtualHost>

The final adjustment is to add the domain name for stkathryns.org into the /etc/hosts file, so I can develop locally, with the correct domain name.

Code:

127.0.0.1 localhost.localdomain localhost stkathryns.org stk

How to kill processes out of a ps list

ps eaux | grep  'uniquestring' | sed "s/^root *\([0-9]*\).*$/\1/" | xargs kill -9

SugarCRM Extension/Modules/Integration Notes

Link: http://sugarcrm.com

  • Under custom/Extension/modules/[module to extend/modify]/Ext/Menus add a [new module].ext.php file with the additional menu options.
  • If you want to change a menu option, loop through the menu array and replace that option with the new one, in the menu.ext.php file.
  • Be sure to rebuild/repair the module before testing changes.
  • Spend a good amount of time looking at the Sugar code as you’re working. It’s very powerful, and the less code you write, the better the solution will be.
  • If you’re just modifying existing functionality, copy as much code as possible, the update it.
  • Understand PHP classes and extensions.
  • Never modify the distributed code.

:: Next >>