Up and running fast with PHP/Apache on Windows 10

With all the various server options available, such as NodeJS, IIS Express, .NET Core offerings, tons of cloud offerings, it’s important to remember that, on the internet today, PHP is still the king, and Apache is its throne. This is not to say or enter into the argument if its the best choice, but it is definitely the most economic choice, being entirely free.

So there’s little reason you shouldn’t have a copy of it to run on your local computer instead of browsing through CPanel on a cheap hosting service and doing a Los Angeles freeway’s worth of traffic uploading file modifications. Just run it locally! It’s not that difficult.

There are a lot of vendors who including handy packages such as MAMP, but these don’t gain you much besides the setup I’m about to outline. Also, the experience of configuring and running a local server is worth the time.

Download PHP and Apache

For this guide, I’m using Apache 2.4.41, and PHP 7.3.7. Get the zips for these first:

Installing PHP

Extract the php zip into a convenient folder on your local drive. C:\php is a safe bet.

Now, in your new php folder, copy and rename the php.ini-development to php.ini. This will cause the php initialization to use the default settings for development, which is good for localhost work.

In the php.ini file, set the extension_dir to your php folder’s ext subfolder:

Enable the following extensions which will be needed by MySQL, in case you plan to use that. (Note: curl is a very common network request tool, and gd2 is a graphics library which comes in handy for manipulating/drawing images).

Open Control Panel and Go to System and Security, and then choose System (Control Panel\System and Security\System).

Once there, click on Advanced system settings. In the popup, under the Advanced Tab, click the [Environment Variables…] button at the bottom:

Edit the Path variable in your Environment Variables:

Click the New button to add to the environment variable list, and add your php folder:

Click OK to both pop-up windows to apply the change.

Install Apache

Now extract the Apache zip to your local drive. The zip I link above has two items in the root, a folder called Apache24, and a readme_first.html file, so we can just extract the whole thing to the C drive.

Go to the extract folder (C:\Apache24), open the conf subfolder, and edit the file httpd.conf

In the httpd.conf file, modify the DirectoryIndex configuration. This will tell Apache that index.php is the first file to look for under a folder it is serving up. Notice I’m keeping the index.html file too, but you don’t have to:

Then, at the end of the file add this:

#PHP
PHPIniDir "C:/php"
LoadModule php7_module "C:/php/php7apache2_4.dll"
AddType application/x-httpd-php .php

Run Apache

Open CMD and run httpd, which you will find under your bin sub folder of the Apache folder (C:\Apache24\bin\httpd.exe)

You may have to allow it throw Windows Firewall on first run:

When this is running, it will won’t write any more to the command line. And if you need to stop it, do CTRL+C. And you will then be prompted if you want to “Terminate Batch Job (Y/N)?”, and the answer is Y.

Both the start-up and shut-down can take a moment. Be patient especially with the shut-down and wait for the terminate prompt.

Testing PHP

The hello world you can use to test your new PHP/Apache setup is the following dirt simple php file:

<?php
echo "Hello World!";
?>

Put this in a text file and save it as index.php in your Apache htdocs folder (C:\Apache24\htdocs\index.php)

Now when you open “localhost” in your browser, if everything installed okay, you should see This:

And the best part is, once you know your PC’s network IP address, you can visit your hosted content from your phone, tablet, other computers etc. Just run ipconfig from the Command Prompt, and look for this piece of information:

So in this case if you browse to http://<Your IPv4 Address>/ on one of these devices or another computer, you should see “Hello World!”.

Easy M4A/AIFF/WMA/ETC to Mp3 conversion with FFmpeg

Making a simple mp3 converter for various audio files

FFmpeg was created as a Linux tool to facilitate movie format decoding. It was later wrapped into the mplayer project, where it remained a stand-alone exe used by the mplayer libraries.

While MPlayer is no more, FFmpeg continues to find its way into countless media production applications, since it does such a good job and offers so many conversion options. If you have a media conversion tool, there’s a good chance FFmpeg is sitting somewhere in the application’s bin folder.

Best of all, it is still available as a free download, and I wouldn’t recommend any other converter for the reason stated above; most converters use FFmpeg.

A lot of WordPress sites cannot recieve the audio formats aiff and m4a which are sometimes produced by media programs. So FFMPEG can help you convert it to the smaller, ultra-portable MP3 format.

The FFMPEG exe handles a sea of arguments, but for simplicity sake I’m just doing the obvious in the following one-liner bat file, which will take an audio file, and convert it to MP3 (128k sample rate) using for output the same file name as passed in with the .mp3 extension instead of the source extension. It will create the output file in the same location as the input. So once you have this file bat file created, you can just drag audio files onto it and see the output file created in the same location.

  • Take the following, and edit the “LOCATION_OF_YOUR_FFMPEG_EXE” part to be the path of where the ffmpeg exe ended up after your download.
  • Save the file to your desktop, or somewhere convenient for dropping files.
  • Drag an audio file from any folder onto the bat file and watch for an MP3 version of it to be created in that same folder.
C:\LOCATION_OF_YOUR_FFMPEG_EXE\ffmpeg.exe -i %1 -acodec libmp3lame -ab 128k "%~n1.mp3"