Quick & Dirty PHP Devel Setup on Windows

Here’s a quick tip if you’re developing a really simple PHP site and need a development setup on Windows with minimal fuss. Don’t bother with a full LAMP stack like XAMPP, which requires you to run a batch file that will rewrite its Apache and PHP configuration files.

PHP version 5.4.0 and above comes with a handy built-in webserver. Simply download the binaries for Windows and unzip it into a directory of your choice. Start the server with the following command and you’re good to go!

php -S localhost:8000 -t <directory>

This will start a web server that listens on port 8000 on localhost with the specified directory as your document root. If you need more control, you can also specify a “router” PHP script that will handle each HTTP request.

When you no longer need to use the “development environment”, just delete the directory which you unzipped PHP into.



GNU patch and Windows UAC

If you’re looking for the GNU patch on Windows, you would probably have found the GnuWin32 project. If you try to run this program on Windows Vista or 7, you will be prompted with the UAC dialog, asking you to run the program with administrative rights.

Windows Vista, when they introduced the User Access Control (UAC) feature, tried not to break existing programs by detecting which ones require administrative access. The usual suspects are installers that are probably named *setup.exe or *install.exe. For some reason they also thought they’d throw in *patch*.exe, which matches the patch.exe.

To fix this problem, I found a page at the OOMMF project at NIST, which talks about embedding a manifest file into the executable. Embedding it is actually not necessary, you just need to name it patch.exe.manifest and have it in the same directory as patch.exe.

The other alternative is to disable this system-wide “smart” detection behavior using a Security Policy: “User Account Control: Detect application installations and prompt for elevation“. If you do this, it means you will need to manually right-click older installer applications and select the “Run as administrator” option. Failing to do this means the installer will not be able to correctly write into directories like “Program Files” and alter system registry settings. Note that when I say “correctly write”, it’s because of the UAC virtualization, but that’s another story.

If you use MSYS (from the MingW project), it uses the patch.exe.manifest file technique, which is less intrusive than embedding it into the executable.

If you’re an application developer, you should read Windows Vista Application Development Requirements for User Account Control (UAC), which describes in detail the different options I have just talked about.


If you need just GNU patch, follow the OOMMF page to create the manifest file, but don’t bother embedding it. If you come from a UNIX background, just use MSYS to get all the other UNIX tools.

Copying files between users in Windows 7

I’ve recently installed Windows 7 on my desktop and I’m trying to migrate files from the laptop’s hard disk.

Whenever I try to copy files from a folder that I do not have permissions to, it asks me if I want to gain “permanent access” to the folder and its contents, which means to alter the folder permissions to take ownership of the folder & files. Why would I want to do that? After the folder is copied to the new user, I would still need to alter the permissions for that user again anyway, which means the permissions are altered twice. Altering permissions on a directory tree is no fast operation either. This problem is also detailed here by sbalfour.

After following some links, the solution is to use the real Administrator account, which needs to be activated first using the following command line. You need to launch the Command Prompt using “run as administrator”.

net user Administrator /active

After the command completes, simply logout and login using the newly activated Administrator account and you can move the files around without being forced to take ownership of the folder & files.

Drag & drop in Windows 7 doesn’t work

I reformatted my computer yesterday and installed Windows 7. I installed 2 apps – Winamp and Mp3tag, both of which cannot accept files that have been dropped onto them. Hmmm… that’s strange.

It turns out that this is a security feature, part of UAC. Instructions on how to fix it is detailed here. In the Control Panel item “Administrative Tools”, under Local Policy, disable this item called “User Account Control: Only elevate UIaccess applications that are installed in secure locations”.

What baffles me is that “Program Files” is listed as a secure location, and so is Windows Explorer right? So why aren’t these programs with elevated access? If they are, can’t they interact with each other via drag & drop?