As a LAMP sysadmin/developer, I have spent plenty of time tuning my IDE and SSH clients to align with my particular workflow and other preferences. For testing purposes and various other reasons, I am committed to a Windows workstation without any unnecessary virtual machine usage. However, there are times when local work just makes more sense and/or the lack of an Internet connection precludes accessing Linux utilities via a remote server. I set out to tailor an installation of cygwin to let me perform local CLI development using the exact same tools and techniques that I use for remote development.
Objective
Be able to SSH to my local Windows 7 machine via Cygwin with the objective of running standard Linux-style scripts, including PHP tools that can be repurposed from remote Linux environments.
Installation Process
I omit PuTTY and SSH general information. If you are not already familiar with both technologies, then Cygwin is less likely to make sense for you.
- Download the Cygwin setup program and launch it
-
During Cygwin setup, select the following packages:
- cygrunsrv
- openssh
- gcc-g++
- make
- libxml2-devel
- curl
- vim
- nano
- In the Start Menu, right-click on Cygwin Terminal and Run as Administrator.
-
In the Cygwin Terminal, run the following three commands:
- ssh-user-config -y
- ssh-host-config -y
- cygrunsrv -S sshd
- Convert SSH key to a PuTTY PPK file
- Configure PuTTY to connect to localhost using that new PPK file
-
Install PHP
- Download PHP source (I tested with 5.3.25)
- SSH to localhost (or use Cygwin Terminal if you are going out of order)
- Change directory to where the source tarball was downloaded (e.g., `cd /cygdrive/c/Users/YourName/Downloads/`)
- Extract the source code folder and go into it (e.g., `tar -xzf php-*.tar.gz; cd php-5.3.25`)
- Configure the compilation: `./configure`
- Compile PHP: `make; make install`
- Within SSH (or the Cygwin Terminal), test it with `php -r 'echo date("Y-m-d");'`