-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstaller.bat
184 lines (167 loc) · 5.46 KB
/
installer.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
@ECHO off
SET wnpsi_v=v1.5.2
TITLE Windows Nginx PHP Stack Installer %wnpsi_v%
COLOR 03
ECHO ___ ___ ___ ___
ECHO /\ \ /\ \ /\ \ /\__\
ECHO _\:\ \ \:\ \ /::\ \ /:/ _/_ ___
ECHO /\ \:\ \ \:\ \ /:/\:\__\ /:/ /\ \ /\__\
ECHO _\:\ \:\ \ _____\:\ \ /:/ /:/ / /:/ /::\ \ /:/__/
ECHO /\ \:\ \:\__\ /::::::::\__\ /:/_/:/ / /:/_/:/\:\__\ /::\ \
ECHO \:\ \:\/:/ / \:\~~\~~\/__/ \:\/:/ / \:\/:/ /:/ / \/\:\ \__
ECHO \:\ \::/ / \:\ \ \::/__/ \::/ /:/ / ~~\:\/\__\
ECHO \:\/:/ / \:\ \ \:\ \ \/_/:/ / \::/ /
ECHO \::/ / \:\__\ \:\__\ /:/ / /:/ /
ECHO \/__/ \/__/ \/__/ \/__/ \/__/ ~~ %wnpsi_v%
ECHO.
pause
ECHO.
SET nginx_v=1.12.2
SET php_v=7.2.4
SET nssm_v=2.24-101
SET vcr_v=2017
CD /d %~dp0
ECHO Where do you want to install Nginx?
ECHO - Press enter to use default and recommended directory: c:\nginx
SET /p "nginx_loc="
IF "%nginx_loc%" == "" (
set nginx_loc=c:\nginx
)
ECHO.
ECHO ############################
ECHO Downloading Requirements
ECHO ############################
ECHO.
ECHO 1. Downloading Nginx %nginx_v%
cscript dl_config\1_nginxdl.vbs //Nologo
ECHO. Done!
ECHO 2. Downloading PHP %php_v%
cscript dl_config\2_phpdl.vbs //Nologo
ECHO. Done!
ECHO 3. Downloading NSSM %nssm_v%
cscript dl_config\3_nssmdl.vbs //Nologo
ECHO. Done!
ECHO 4. Downloading Visual C++ Redistributable for Visual Studio %vcr_v%
cscript dl_config\4_vcr.vbs //Nologo
ECHO. Done!
ECHO.
ECHO Download Completed...
ECHO.
ECHO #############################
ECHO Unzipping Files
ECHO #############################
ECHO.
ECHO 1. Unziping Nginx
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('nginx.zip', '.'); }"
ECHO. Done!
ECHO 2. Unziping PHP
powershell -Command "(Add-Type -AssemblyName System.IO.Compression.Filesystem)"
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('php.zip', 'php'); }"
ECHO. Done!
ECHO 3. Unziping NSM
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('nssm.zip', '.'); }"
ECHO. Done!
ECHO.
ECHO ####################################
ECHO Moving Nginx to destination
ECHO ####################################
ECHO.
MOVE %~dp0nginx-* nginx >nul 2>&1
MOVE %~dp0nginx\html %~dp0nginx\www >nul 2>&1
ROBOCOPY %~dp0nginx %nginx_loc% /E /MOVE /NFL /NDL /NJH /nc /ns /np
ECHO.
ECHO ####################################
ECHO Moving PHP to destination
ECHO ####################################
ECHO.
ROBOCOPY %~dp0php %nginx_loc%\php /E /MOVE /NFL /NDL /NJH /nc /ns /np
ECHO.
ECHO #############################
ECHO Moving NSSM to destination
ECHO #############################
ECHO.
MOVE %~dp0nssm-* nssm >nul 2>&1
ROBOCOPY %~dp0nssm\win64\ C:\Windows\System32 /E /MOVE /NFL /NDL /NJH /nc /ns /np /R:0 /W:1
ECHO.
ECHO #############################
ECHO Creating Nginx service
ECHO #############################
ECHO.
ECHO In order to save and reload Nginx configuration, you need to run the NGINX service as the administrator
ECHO.
ECHO Username: %username%
set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
for /f "usebackq delims=" %%p in (`%psCommand%`) do set pass=%%p
ECHO.
NSSM install NGINX %nginx_loc%\nginx.exe
NSSM set NGINX ObjectName %userdomain%\%username% %pass%
NSSM start NGINX
NSSM restart NGINX
ECHO.
ECHO Installing Visual C++ Redistributable for Visual Studio 2017 [PHP 7+ req]
vc_redist.x64.exe /q /norestart
ECHO.
ECHO #############################
ECHO Creating PHP service
ECHO #############################
ECHO.
NSSM install PHP %nginx_loc%\php\php-cgi.exe
NSSM set PHP AppParameters -b 127.0.0.1:9000
NSSM set PHP ObjectName %userdomain%\%username% %pass%
ECHO.
ECHO Setting PHP system variables
SETX /m PHP_FCGI_CHILDREN 3
SETX /m PHP_FCGI_MAX_REQUESTS 128
ECHO.
NSSM start PHP
NSSM restart PHP
ECHO.
ECHO #############################
ECHO Updating Nginx and PHP config
ECHO #############################
ECHO.
COPY %~dp0config\nginx.conf %nginx_loc%\conf\nginx.conf
CD /d %nginx_loc%
nginx -s reload
CD /d %~dp0
COPY %~dp0config\php.ini %nginx_loc%\php\php.ini
COPY %~dp0config\index.php %nginx_loc%\www\index.php
CD /d %nginx_loc%
nginx -s reload
CD /d %~dp0
NSSM restart PHP
NSSM restart NGINX
ECHO.
timeout /t 4 /nobreak
SET /p "=Nginx status : " <nul
NSSM status NGINX
SET /p "=PHP status : " <nul
NSSM status PHP
ECHO.
ECHO ########## Installation Completed ##########
ECHO.
SET /p "=To test your install [http://localhost] " <nul
pause
START http://localhost
ECHO.
ECHO ############################
ECHO Cleaning up downloaded Files
ECHO ############################
ECHO.
DEL /s /q %~dp0nginx.zip >nul 2>&1
ECHO nginx.zip DELETED
DEL /s /q %~dp0php.zip >nul 2>&1
ECHO php.zip DELETED
DEL /s /q %~dp0nssm.zip >nul 2>&1
ECHO nssm.zip DELETED
DEL /s /q %~dp0vc_redist.x64.exe >nul 2>&1
ECHO vc_redist.exe DELETED
RMDIR /s /q nssm >nul 2>&1
ECHO nssm directory DELETED
ECHO.
ECHO Done!
ECHO.
SET /p "=Exit: " <nul
pause