Skip to content

Instantly share code, notes, and snippets.

@halilim
Created August 25, 2013 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halilim/6334877 to your computer and use it in GitHub Desktop.
Save halilim/6334877 to your computer and use it in GitHub Desktop.
Simple Apache/PHP version switcher. Assumes there are folders like "php5.4", "Apache2.4Win64VC11", "php5.5VC11x64ts" etc with php and Apache unzipped. Usage: switch 2.4 5.5
:: Simple Apache/PHP version switcher. Assumes there are folders like "php5.4",
:: "Apache2.4Win64VC11", "php5.5VC11x64ts" etc with php and Apache unzipped.
:: Usage: switch 2.4 5.5
@echo off
:: Get Apache service version, e.g. 2.2/2.4
set ApacheName=%1
set ApacheServiceVersion=%ApacheName:~0,3%
:: Stop and remove existing Apache services
sc stop Apache2.2
sc delete Apache2.2
sc stop Apache2.4
sc delete Apache2.4
:: Wait for the existing service to stop (release port 80 etc)
timeout 10 /nobreak
:: Adjust symlinks
rmdir Apache
mklink /D Apache Apache%1
rmdir php
mklink /D php php%2
:: Install and start the new service
Apache\bin\httpd -k install
sc start Apache%ApacheServiceVersion%
:: Create a "current-Apache*-php*" file as a visual indicator
del /Q current-*
type nul > current-%1-%2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment