Configuring IIS7 without the GUI
If you’re like me, you’re pretty used to using a text editor to set up your webserver and find gui’s quite frankly annoying (and you can’t store them in $insert_your_vcs_of_choice)
But IIS7 actually holds all it’s configuration in plain XML files, which are really quite easy to edit by hand. It’s just a question of WHERE these files end up.
I’m not going to go into the details of all the options and xml necessary, but here are a few tips.
By default a web.config file is placed in the webroot of whatever site you’ve set up – this should be used for site local configuration
For me this means defaultDirectory information (index.php is my friend) and rewrite rules (if you’re not using URL Rewrite you’re insane)
Your “overall” web server configuration is hidden really well. It’s in your windows directory – usually c:\Windows but your location may vary
so head to C:\Windows\System32\inetsrv\config and you’ll find those nice hidden config files. Now, technically you won’t be allowed to edit those files, but as long as you have Admin privileges on the windows machine, here’s the dirty trick. Drag the file out of the directory onto your desktop. Edit and save, drag it back in place.
The file you’re probably interested in is applicationHost.config The reason I initially went hunting for it was to set a PHPRC environment variable, so silly PHP gets the right .ini file. But because I have many PHP versions installed I did NOT want to have that set as a system wide variable. I also could set up an APPLICATION_INI variable for Zend Framework, which happened to be running on that version of PHP. AND I could set two versions of PHP to run, and tell the site configuration which one to use.
<fastCgi>
<application fullPath="C:\Program Files (x86)\php-5.3.1-nts\php-cgi.exe"
arguments="" monitorChangesTo="" stderrMode="ReturnStdErrIn500"
maxInstances="4" idleTimeout="300" activityTimeout="30"
requestTimeout="90" instanceMaxRequests="200"
protocol="NamedPipe" queueLength="1000" flushNamedPipe="false"
rapidFailsPerMinute="10">
</application>
<application fullPath="C:\Program Files (x86)\php-5.2.12-nts\php-cgi.exe"
arguments="" monitorChangesTo="" stderrMode="ReturnStdErrIn500"
maxInstances="4" idleTimeout="300" activityTimeout="30"
requestTimeout="90" instanceMaxRequests="200"
protocol="NamedPipe" queueLength="1000" flushNamedPipe="false"
rapidFailsPerMinute="10">
<environmentVariables>
<environmentVariable name="PHPRC" value="C:\htdocs\config" />
<environmentVariable name="APPLICATION_INI"
value="C:\htdocs\config\local_app.ini" />
</environmentVariables>
</application>
</fastCgi>
Now that I know where the files hide, and have taken some time to figure out all the xml available (I spent some time reading the reference, just as I had to learn apache’s configuration information) I can store my configurations and set up new servers quickly and easily.
Notice, just like apache httpd.conf changes, you’ll have to restart your webserver if you change the xml
Cairo Alpha Released
The first alpha of the PECL Cairo extension I’ve been working on is finally out. Cairo is a 2D graphics library written in C with support for multiple output devices. The extension provides an Object Oriented API, but also includes procedural methods. This is similar to PHP’s date and mysqli extensions. The reason for the dual API is to support users of the cairo-wrapper extension. If you have code using cairo-wrapper currently, you can ‘drop in’ the new extension as a replacement with one caveat – cairo-wrapper used resources, the new cairo extension uses objects, so any is_resource() checks would fail.
The extension provides support for PHP 5.2.x and 5.3.x only. It requires the CairoGraphics Library version 1.4 and higher – all the way to 1.8. If you know anything about the cairo graphics library, you know that it uses even version numbers for ’stable’ releases and odd ones for unstable. You can use unstable library versions with the cairo extension, but it will only have the features of the earliest version before – for example a 1.9.2 snapshot would only have 1.8 features enabled.
PECL cairo is currently labeled alpha because the API is not yet complete. I’m still working on finishing 3 surface backends that aren’t wrapped (Xlib, Win32 and Quartz) and backend fonts. Only the toy font face API methods are currently ready, so there are a few glyph related functions that aren’t implemented or just don’t do anything. In addition there are some random items (supporting cloning matrices and paths, for example) that are on the TODO list.
Windows builds are available at the homepage for the extension – as well as the documentation. We’re having some “fun” getting permission to use stuff from the Cairo library docs because they’re all embedded in the source code, which makes licensing a pain. So for now the docs are on the homepage and NOT in the php manual – licensing sucks.
Feedback is always welcome, as is any help in writing documentation or even feature requests.
So download it, give it a try, run the test suite (windows users, there’s a package set up to help with that), run the examples, have fun.
Ada Lovelace Day 2009
In the normal course of a day I tend to volunteer for far more things than I have time to complete. This has happened once again for Ada Lovelace Day. I can never say no to crazy pledges so here I am with a very short expression of thanks to someone who has helped me in my walk through the insanity of programming.
I’ve been using PHP for a long time, since one of the 4 betas. But my foray into C and the internals of PHP is only about two years old. I never would have had the confidence or learned the skills I needed to transition from “just another PHP developer” into something more without the help of Sara Golemon.
Sara works for Yahoo! and has her fingers on so many PHP extensions that it might make you dizzy (oooh shiny syndrome… we all have it). When I was first starting to leap into C and learn both the basics and the weirdness that is on the inside of PHP, she was always there to answer questions no matter how stupid. Some were VERY stupid (pointers took me a bit).
That hand-holding in the beginning, and her encouragement (yes, you write nice clean C code always makes a person smile) gave me the confidence to keep going even when segfaults made me want to hurl the machine out the window.
I can remember a particular incident where I was giving a talk on an extension that had some issues I hadn’t quite figured out. She took the time (and we even had a drunken coding session instead of partying more) to help get it ready in time for the talk.
Finally there’s the note written in my copy of her book – it says “Welcome to Evil” – in the true spirit of mentorship she was happy to help me get “up to speed” no matter her cost in time and energy.
So thanks Sara, for all the questions answered no matter how foolish and the encouragement to keep coding.
Xdebug, Thread Safety, and PHP 5.3
There have been some changes to internal PHP stuff for 5.3, and some don’t always show up unless you’re looking at your compile logs and testing with thread safety on.
Currently Xdebug will crash and burn if you’re using it with 5.3 and ZTS on – I’m sure Derick will get it fixed when he’s back from vacation
But not everyone can wait and I needed it sooner so I fixed my local copy. I didn’t have the time to do a proper patch yet (use a macro so it compiles against 5.2 as well) but you’re welcome to the source. Notice it will only compile against php 5.3.
If you’re using windows and testing/playing with 5.3 alpha/beta builds or snapshots and xdebug is crashing for you (most likely because you’re trying to use code coverage or pretty var dumps, the two areas where the issues show up) you can grab a patched compile until the next release.
Trying on some new looks
Been looking around for a pretty pink theme for awhile, so don’t be surprised if the look of this blog changes a lot over the next few days while I experiment.