Yet another one of those "How to Setup a WEMP Stack" how-to. While other users prefer to get it done simply; I want to get down and dirty to keep things organized in my own liking.
Packages
There is an alternative way in installing the packages by using the Chocolatey package manager. The only caveat is you can't customize the installation directory in the free version. If you're willing to shell out $96/yr to free you of worry. Then why not?
* Download the Non Thread Safe as it fits with Nginx
Setting Up
You could create a directory under any drive of your choice with my existing structure as reference.
/c/Dev/Bin /c/Dev/Programs : /nginx : /php /c/Dev/Code
There is a Bin folder included which we will use to add it in our system path and linking binaries using batch and bash.
In the Bin folder we will have a batch script that acts a runner to boot up Nginx and PHP. It is a modified version of the original batch script I have been using over the years.
/c/Dev/Bin/servers.cmd
@echo off | |
:: WEMP Runner | |
SETLOCAL | |
:: Server Runner | |
SET "root=%CD:~0,3%" | |
SET "dev=Dev\" | |
SET "bin=Bin\" | |
:: Nginx variables | |
SET "nginxdir=%root%%dev%%bin%nginx\" | |
SET "nginxcfg=%nginxdir%conf\nginx.conf" | |
SET "nginxins=nginx.exe" | |
:: Global PHP variables | |
SET "phpbpt=127.0.0.1:9000" | |
SET "phpcgi=php-cgi.exe" | |
SET "phpcfg=php.ini" | |
:: Common PHP INI (Extensions should be equally distributed to all versions) | |
SET "phpdir=%root%%dev%%bin%php\" | |
:: PHP 7.2.* (7.2.*) variables [NTS~x64] | |
SET "php72ins=%phpdir%7.2\" | |
SET "php72cfg=%phpdir%7.2\" | |
:menu | |
cls | |
c: | |
echo Server Runner | |
echo -- | |
echo (1) : Nginx + PHP7.2(NTS) x64 | |
echo -- | |
echo (s) : Stop Server Components | |
echo -- | |
echo (x) : Exit | |
set input=nothing | |
set /p input=Choice: | |
if %input%==1 goto startNginxPHP72 | |
if %input%==s goto stop | |
if %input%==x goto exit | |
goto menu | |
:startNginxPHP72 | |
cls | |
d: | |
echo Starting Nginx | |
start /B %nginxdir%%nginxins% -c %nginxcfg% -p %nginxdir% | |
echo Starting PHP 7.2 NTS FastCGI | |
start /B %php72ins%%phpcgi% -b %phpbpt% -c %php72cfg%%phpcfg% | |
pause | |
goto menu | |
:stop | |
cls | |
taskkill /f /im nginx.exe | |
taskkill /f /im php-cgi.exe | |
pause | |
goto menu | |
:exit | |
cls | |
exit |
Finally add "C:\Dev\Bin" to your path of your environment variables. Now you can now call "servers.cmd" in MINGW64 or "servers" in Command Prompt.