VerySimple Developer Blog
Technical Tips, Tricks and Rants.

Archive for the ‘Operating Systems’ Category

 
Jan
05
Filed Under (Announcements, IIS, PHP, Windows) by Jason on 05-01-2008

After Installing PHP 5 using the Windows installer on Windows 2003 you may find that IIS displays a “Page Not Found” 404 error for every .php page. This is a perplexing error because is it not actually a real 404 error. The file is really there, but IIS is unable to process it based on how the installer configures the extension mapping. Instead of providing any useful information or even a 500 error; however, IIS throws out a 404.

Steps to Fix the Problem:

Before you troubleshoot further, you may want to read #4 about how the Application Pool effects PHP configuration changes.

1. Replace the old DOS format path to the PHP Executable with a full path w/ quotes
2. Move php.ini to C:\Windows
3. Edit php.ini to set cgi.force_redirect = 0 (possibly not necessary)
4. Recycle the Application Pool

1. Replace the old DOS Path Format

Edit Map

The default path to PHP is C:\Program Files\PHP. When creating the IIS extention mapping, the PHP Installer uses the old DOS format path to the PHP ISAPI or CGI executable such as “C:\PROGRA~1\PHP\PHP5IS~1.DLL”. IIS does not seem to like this format. To fix the problem, go to the IIS Extension Mapping screen and locate the value for “.php” (See screenshot above). Click the browse button, select the executable and put quotes around it the entire path. So the value for this field should look like this “C:\Program Files\PHP\php5isapi.dll” (WITH the quotes around it). If you have installed PHP in CGI mode instead, the file name would be php-cgi.exe instead of php5isapi.dll

While you’re at it you may want to check the box for “Verify that file exists” as well. This allows IIS to handle actual missing pages (ie broken links) and return a 404. Otherwise IIS will just pass the request to PHP without verifying the .php file really exists and PHP throws a CGI error when the file isn’t found. People seem to have inconsistent results with this setting.

If you recycle the app pool at this point (see step #4) you *may* solve the 404 error depending on what extensions you installed or whether you had re-run the installer and changed stuff. However, you may still have issues changing php.ini settings in which case keep reading.

2. Copy php.ini to C:\Windows

The PHP installer creates a php.ini file for you based on your selections in the setup process. However the installer saves the file in C:\Program Files\PHP. The problem is that PHP is looking in C:\Windows for the .ini file. So, you need to move the file php.ini to C:\Windows. This may be confusing because PHP seems to run fine. But if you look closely at the phpinfo() output, you may find that php.ini file is not being loaded and all default settings are being used.

One of the critical things when configuring PHP is to actually edit the .ini file that is being used by PHP. The installer creates a worthless file in a location that PHP won’t read and so you may waste a lot of time editing this file. PHP pretty much universally will check the Windows folder for php.ini on all varieties of Windows, so my advice is to use that location and delete any other php.ini files that are hanging around..

3. Set cgi.force_redirect = 0 (Optional..?)

Some people report that you need to edit php.in, un-comment the cgi.force_redirect parameter and change the value like so:

cgi.force_redirect = 0

I have not found this to make any difference, but your mileage may vary. Obviously make sure #2 is straight first and that you are editing php.ini in the correct location so that your changes take effect.

4. Recycle the Application Pool

In order for any PHP configuration changes to take effect in Windows 2003, you need to recycle the Application Pool. If you have made changes to php.ini and they don’t seem to take effect, this is likely the reason. Among other things, the pool caches PHP settings and you need to clear it before new configuration settings will take effect. You’ll read people telling you to restart IIS (which doesn’t recycle the app pool) or even reboot your machine (which is overkill). You don’t need to do either of those. Just right-click on the DefaultAppPool in the IIS management interface and “Recycle” is one of the options.

Recycle Pool

If I’m having trouble with the ini file, I like to have a typical phpinfo.php file on the server while I make some arbitrary change to the php.ini file (like the session timeout or the max upload size). I refresh phpinfo.php and verify that my changes are taking effect. You can also check the Windows Event logs under “System” which will sometimes report errors in the php.ini file.

Notes regarding re-running the PHP installer to make changes:

The PHP installer does not really handle changes all that well. For one thing it will overwrite the path to the PHP executable w/ the old DOS format so you need to fix that after you run it.

The 2nd thing is that it will write changes to C:\Program Files\PHP\php.ini - regardless of the fact that PHP is actually looking at C:\Windows\php.ini

If you had previously moved php.ini to the windows folder, when you run the Change installation feature, it will create a fresh php.ini file that only incorporates the most recent changes. (ie, if you had 10 extensions enabled and you make a change to enable 1 more, your new php.ini file will only have the 1 enabled and the previous 10 will no longer be enabled)

One way around this is to temporarily move C:\Windows\php.ini file to C:\Program Files\PHP. Then run in installer to make changes. The installer will write changes to php.ini in that location. Then, move php.ini back to C:\Windows.

 

 
Oct
18
Filed Under (Announcements, OSX) by Jason on 18-10-2007

OSX 10.5 Leopard may show the following error in the console when opening certain Java applications in Rosetta:

JavaVM FATAL: Java for ppc cannot run in this configuration.
JavaVM FATAL: Please consult documentation.

This error appears in PPC applications that have a Java component and are trying to use an older version of the Java runtime. Apple seems to have not included the complete 1.3.1 JDK with Leopard, instead the 1.3.1 folder simply contains an alias to the Java application launcher.

A patch file LeopardJavaPatch.zip includes a replacement for the 1.3.1 JDK that resolves the issue in some cases. Installation is easy - simply unzip the archive and follow the instructions to update your 1.3.1 JDK folder.

If this doesn’t solve your problem, you can also try downgrading the JDK using the instructions included in the “Advanced” section of the LeopardJavaPatch.zip ReadMe. Or alternatively macoshints.com provides a script to manage your system JDK settings.

Please note that this patch only fixes issues for Leopard. If you are running Tiger or an earlier version, then you are more likely to solve your problem by downgrading the JDK (see above).

If you have any comments or additional information about this error, please feel free to leave a comment.

 

 
Aug
22
Filed Under (*NIX, Announcements) by Jason on 22-08-2007

wget in combination with cron is a useful utility for automating processes in a web application. It’s possible to run most scripting languages from the command line, but sometimes it’s tricky to get those to run correctly when they don’t have the server context.

One simple way to achieve this is to write your automation functions as a regular web-based page within the app and then use wget to post a web request to that URL. You can use cron to schedule the frequency.

wget is fairly simple to use, however one thing that is difficult to find in the documentation is how to get the contents of the document and append them to a file. The normal behavior is to just download the file and save it with it’s original name. You can remedy this by specifying a dash “-” as the output filename, which tells wget to output the document to the console. the –quiet parameter tells wget not to output a bunch of connection info. Finally, we redirect the console output to append to a file using >> at the end. The resulting statement looks something like this:

wget --quiet --output-document=- http://localhost/auto.php?arg=123 >> /path/to/file.log

Depending on your server configuration you may need to put quotes around your URL as well, like so:

wget --quiet --output-document=- "http://localhost/auto.php?arg=123" >> /path/to/file.log

If you are attempting to connect to a secure URL (beginning with “https”), you may also need to add the “–no-check-certificate” option to the command in which case your command would like like so:

wget --quiet --no-check-certificate --output-document=- "https://localhost/auto.php?arg=123" >> /path/to/file.log

If you have your automation script output debug information, then your logfile will contain useful information. As an example, I like to output the date and time that the script runs and then any info about failures that may have occured.

One note about security - if you don’t want people poking around and firing off your automation and/or viewing your debug information, you should implement some type of security, such as a simple username/password arguments or something more robust if required.

 

« Previous Entries
Close
  • Social Web

NOTE: Email is disabled

E-mail It