03.05.10
Posted in System Administration, Web Development at 6:27 pm by BrianS
One of the nice things about CakePHP is that it attempts to make a site more friendly to the average web site visitor by creating easier-to-remember URLs. There are a few techniques that CakePHP uses, but for the sake of this conversation we’ll focus on one way in particular: apache’s mod_rewrite functionality. Using mod_rewrite, URLs that would normally include the controller file (index.php) and a querystring can be rewritten as a simple file path.
Microsoft doesn’t include mod_rewrite-style functionality in IIS by default, though it has created an extension for IIS7. Since we are currently using IIS6 the extension isn’t an option for us. Fortunately there are a few other options available, including an open-source project called Ionics Isapi Rewrite Filter (IIRF). IIRF is an ISAPI filter that is very similar to mod_rewrite in terms of functionality. After some testing I’ve found this filter works almost perfectly for enabling CakePHP’s friendly URLs.
Getting Started
Installation is painless and requires only a few steps. The following is based on the IIRF 2.0.1.15 release which does not include an installer:
- Extract the files from the IIRF archive to a folder on the server.
- Open the properties of the IIS root “Web Sites” folder or the specific site that needs IIRF.
- In the “ISAPI Filters” tab create a new entry for IIRF; name the new filter (e.g. “IIRF”); specify the IIRF DLL located with the extracted IIRF files at \bin\IIRF.dll.
- Ensure that the IIS user has read/execute access to the IIRF DLL and read/write access to any directories that will be used for logging.
- Restart IIRF.
IIRF should now be installed, but I’ve found that sometimes the filter won’t appear to be active in the “ISAPI Filters” tab until it has been used the first time. To enable IIRF all you have to do is create a file called IIRF.ini and place it in the web site root folder or in the root of a virtual directory. This file contains any local configuration directives (such as log directory) and URL rewriting rules.
The obligatory gotcha
I mentioned before that the filter works almost perfectly. The only situation where I’ve had problems up to now is if the URL contains one or more space characters. The IIRF log indicates that a URL with a space is being parsed correctly and returning a valid URL. And yet the web server reports a 404 error.
I’ve only done testing when the final URL references a physical file, but based on a conversation in the support forum I suspect this problem also affects parameters in the querystring. I haven’t yet had a chance to fully investigate the issue, so I don’t have a work-around yet when the issue affects physical files. There does, however, appear to be a work-around for spaces in the querystring.
For now I have decided to ensure that any URLs parsed by IIRF that will point to a physical file/directory does not contain spaces.
References
CakePHP usage:
Space-in-URL problems:
Permalink
05.08.09
Posted in System Administration, Web Development at 5:28 pm by BrianS
Often in the course of developing a project it is desirable to use code from a third party. The main benefit, of course, is being able to add functionality without developing that functionality from scratch. Some third-party projects we have used in the past include FCKEditor (now CKEditor), the Yahoo! User Interface library, and, more recently, the CakePHP framework.
When our code is maintained in a subversion repository there are two options for including third-party code: externals and vendor branches. Read the rest of this entry »
Permalink
10.03.08
Posted in Apache, System Administration at 1:57 pm by BrianS
A note way past due.
I updated the log format for flora.p2061.org (but not the other sites on flora). Some information is not included in the default “combined” format that could help with debugging (such as user cookies). I set up a new format that is similar to the IIS W3C extended format. Two values not included that could prove useful are bytes received (%I) and bytes sent (%O). The logio_module has to be enabled to record this information. It would probably be worthwhile to add this functionality once we start placing more public content on the server. For now the following format suffices:
#Fields: date time c-ip cs-host cs-version cs-method cs-uri-stem cs-uri-query cs(Referer) cs(User-Agent) cs(Cookie) sc-status time-taken
LogFormat "%{%Y-%m-%d %H:%M:%S}t %h %V %H %m %U %q %{Referer}i %{User-Agent}i %{Cookie}i %>s %D" webapp
Permalink
08.14.08
Posted in PHP, System Administration at 4:32 pm by BrianS
I needed to do a mass resampling of around 280,000 images. There are a number of ways to do this, but I settled on doing it via PHP because the images are stored on our web server, the total size of the images is large (~10GB), and I didn’t want to kill my machine trying to get it done.
PHP is ideal for a task such as this: parsing directories and subdirectories for images is easy; resampling using the built-in library (GD) is a breeze; specifying the destination as a subdirectory is simple. The one minus was processor usage. Performing image manipulation eats up the CPU in a big way.
Luckily linux systems have a built-in utility for addressing a situation like this: nice. nice will “run a program with modified scheduling priority.” I’m running the image manipulation script using the following command:
nice --adjustment=19 php script.php
If nothing else is going on the script will use whatever resources are available. When anything with a higher priority executes, that program will take precedence over the script with regard to system resources. The script should thus not affect the responsiveness of the web server. This is the reason I was searching for this kind of functionality.
Permalink
05.21.08
Posted in PHP, System Administration at 3:25 pm by BrianS
I recently wanted to update our install of WordPress to the latest version. WordPress is a fairly easy install, and we could learn a thing or two about application set-up by examining their code. But I recently switched to using subversion to deploy and maintain our install. In just the little bit I’ve used subversion so far, I believe development and deployment of our internal applications would be simplified by employing it for all our projects. Here’s a quick outline of the process, with examples based on my WordPress deployment.
Read the rest of this entry »
Permalink
05.07.08
Posted in MySQL, System Administration at 1:55 pm by BrianS
Since we’ll be exposing MySQL to significantly more traffic (due mainly to the transition to a database-driven version of Benchmarks Online [dbBOL]) I decided to spend some time optimizing the server’s settings. There are a number of settings that can be tweaked to improve performance. I based my decisions on the information available from the references cited and the performance statistics reported by MySQL (SQL SHOW VARIABLES or use PHPMyAdmin). MySQL has been running for 131 days as of the writing of this post (see cached copy of the runtime stats), so I expect the data will be a fairly good indication of the performance of MySQL under its current usage. Unfortunately, I expect the usage pattern to change significantly once dbBOL is released. As a result some of the settings used will be based on expected usage patterns. At specific intervals after dbBOL is released we should examine the performance of MySQL based on the runtime stats to determine if additional tweaking needs to be performed. I recommend the following schedule: 1 week, 1 month, 3 months, then every 6 months.
Read the rest of this entry »
Permalink
04.02.08
Posted in System Administration, Web Development at 1:42 pm by BrianS
The data for Benchmarks Online (BOL) is pulled from various tables in the Items database. Some of these tables are also used for the Atlas Statements Database (ASD). Since staff would like for the statements in the ASD to reflect the most recent working version we needed a way to prevent this from affecting BOL, which needs to maintain a stable set of publicly available statements. As a temporary resolution the tables that are used to populate BOL have been copied into a new database called Standards. Going forward, if the content of these tables is updated and those updates need to also be reflected in BOL both copies of each table should be updated.
A long-term goal is to develop a system to contain information related to our standards documents (namely Benchmarks and Atlas). This new system should implement some kind of versioning capability so that we can maintain stable and working copies of the benchmarks statements. This would also allow us to keep better track of how resources are aligned to statements. Currently as a statement is modified we have no way of knowing the wording to which a resource has been aligned.
Permalink
03.11.08
Posted in PHP, System Administration at 9:53 am by BrianS
IIS can’t find php.ini
I installed PHP on the Windows server today and ran into what seems to be a fairly common problem (BrianW can affirm): sometimes PHP is unable to find the php.ini file when processing web-based content. In my case PHP was installed as an ISAPI filter. I suspect that when using the ISAPI filter PHP must be looking in the in the location IIS is running from, rather than the location of the ISAPI DLL (which is located in the PHP folder).
To address the problem I added a PHPRC environment variable. Now everything seems to work as expected. There are a number of options for specifying the location of the php.ini file. See the PHP documentation for runtime configuration.
IIS returns an error
If you’ve fully set up PHP and configured IIS correctly (including enabling the Web Service Extension) then one last thing to check is the path to the DLL specified for the Web Services Extension vs. the value for the application extension in the web site properties. These should match exactly.
Permalink
02.29.08
Posted in System Administration at 5:15 pm by bwalker
Yesterday we were unable to connect to floradev via ssh or browser. The VM control panel indicated ther server was running, no apparent alarms/warnings or recent maintenance. We restarted the server, which seemed to correct the problem. Today, the same problem. Restarted the server again and inspected log files. After about 30 mins while looking through the log files via ssh the connection was dropped, possibly due to inactivity (I was viewing the log with vi rather than tail), but again the server is not accepting new connections. Yesterday after the reboot, I was interacting with the server regularly and never lost the connection while I was working. In addition, I closed and reopened the connection multiple times. This leads me to believe it has something to do with the idle/power-save or some related feature.
The only atypical log entry around the last failure:
feb 29 16:37:02 floratest syslog-ng[3165]: STATS: dropped 0
However, this event is logged regularly.
Another reason I think this related to the power-save is some error messages noted during reboot:
Feb 29 17:05:35 floratest rcpowersaved: CPU frequency scaling is not supported by your processor.
Feb 29 17:05:35 floratest rcpowersaved: enter ‘CPUFREQD_MODULE=off’ in /etc/sysconfig/powersave/cpufreq to avoid this warning.
Feb 29 17:05:36 floratest rcpowersaved: Cannot load cpufreq governors – No cpufreq driver available
Feb 29 17:05:36 floratest [powersave]: ERROR (CPUFreq_Userspace:42) Could not set userspace governor, seems as if the cpufreq_userspace module is not loaded.
Feb 29 17:05:36 floratest [powersave]: ERROR (read_line:43) Could not open file for reading: ‘/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies’
Feb 29 17:05:36 floratest [powersave]: ERROR (read_line:43) Could not open file for reading: ‘/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq’
Feb 29 17:05:36 floratest [powersave]: ERROR (read_value:82) Could not read value in file /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq: error: No such file or directory!
Feb 29 17:05:36 floratest [powersave]: ERROR (read_line:43) Could not open file for reading: ‘/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq’
Feb 29 17:05:36 floratest [powersave]: ERROR (read_value:82) Could not read value in file /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: error: No such file or directory!
Feb 29 17:05:36 floratest [powersave]: WARNING (getMinMaxSpeeds:349) Speedstepping not supported! Was the correct cpufreq module loaded?
Feb 29 17:05:36 floratest [powersave]: WARNING (initFreqsViaTesting:377) Could not read min and max speed
Feb 29 17:05:36 floratest [powersave]: ERROR (PM_Interface:231) Cannot create cpufreq objects
These errors were also reported in a reboot that occurred last night.
This is a link to a post of someone experiencing similar problems, but no solution was posted:
http://groups.google.com/group/alt.os.linux.suse/msg/50d790f2caf4edca
Permalink
02.11.08
Posted in System Administration at 12:27 pm by bwalker
The researchers reported a problem uploading images while using the Add New Items section of the Items Utility.
The researchers were unable to access the upload server directory via the fckeditor (from the fck interface, hit image upload icon and then ‘browse’ server… js error, popup interface is non-functional). Error messages indicated a connector error. I traced this to a setting in the fckconfig.js. The fileBrowserLanguage setting was set to asp instead of php. In addition, I found there were some other mods missing. Somehow fckconfig.js was reverted back to an earlier/original version.
I found a more recent version on my local machine (last update 5/2007) which seemed to correct the problem. However, I’m not sure when I downloaded my version (so I don’t know how old it is), and I don’t know if BS has made any revisions since 5/2007.
This is the version I uploaded: fckconfig
Permalink
« Previous entries Next Page » Next Page »