Run Multiple Php Versions Apache

Τίτλος

No changes

Permalink

No changes

Περιεχόμενο

OldNew
1# How to run multiple PHP versions with Apache1# How to run multiple PHP versions with Apache
22
3```conf C:\xampp\conf\extra\httpd-xampp.conf3**C:\xampp\conf\extra\httpd-xampp.conf:**
44
5# 5```conf
62. XAMPP settings6#
73. 7# XAMPP settings
88#
99
1010<IfModule env_module>
11 SetEnv MYSQL_HOME "\xampp\mysql\bin"11 SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
12 SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"12 SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
13 SetEnv TMP "\xampp\tmp"13 SetEnv TMP "\\xampp\\tmp"
1414</IfModule>
1515
1616#
17# 17# PHP Setup
182. PHP Setup18#
193. 19
2020# PHP 7.4
21# PHP 7.421ScriptAlias /php74 "C:/xampp/php74"
2222Action application/x-httpd-php74-cgi /php74/php-cgi.exe
23ScriptAlias /php74 "C:/xampp/php74" Action23<Directory "C:/xampp/php74">
24application/x-httpd-php74-cgi /php74/php-cgi.exe 24 AllowOverride None
2525 Options None
26 AllowOverride None26 Require all denied
27 Options None27 <Files "php-cgi.exe">
28 Require all denied28 Require all granted
29 29 </Files>
30 Require all granted30</Directory>
3131
32 32# PHP 8.0
3333ScriptAlias /php80 "C:/xampp/php80"
3434Action application/x-httpd-php80-cgi /php80/php-cgi.exe
3535<Directory "C:/xampp/php80">
36# PHP 8.036 AllowOverride None
3737 Options None
38ScriptAlias /php80 "C:/xampp/php80" Action38 Require all denied
39application/x-httpd-php80-cgi /php80/php-cgi.exe 39 <Files "php-cgi.exe">
4040 Require all granted
41 AllowOverride None41 </Files>
42 Options None42</Directory>
43 Require all denied43
44 44# PHP 8.1
45 Require all granted45ScriptAlias /php81 "C:/xampp/php81"
4646Action application/x-httpd-php81-cgi /php81/php-cgi.exe
47 47<Directory "C:/xampp/php81">
4848 AllowOverride None
4949 Options None
5050 Require all denied
51# PHP 8.151 <Files "php-cgi.exe">
5252 Require all granted
53ScriptAlias /php81 "C:/xampp/php81" Action53 </Files>
54application/x-httpd-php81-cgi /php81/php-cgi.exe 54</Directory>
5555
56 AllowOverride None56# PHP 8.2
57 Options None57ScriptAlias /php82 "C:/xampp/php82"
58 Require all denied58Action application/x-httpd-php82-cgi /php82/php-cgi.exe
59 59<Directory "C:/xampp/php82">
60 Require all granted60 AllowOverride None
6161 Options None
62 62 Require all denied
6363 <Files "php-cgi.exe">
6464 Require all granted
6565 </Files>
66# PHP 8.266</Directory>
6767
68ScriptAlias /php82 "C:/xampp/php82" Action68# Default PHP Handler
69application/x-httpd-php82-cgi /php82/php-cgi.exe 69Action application/x-httpd-php-cgi /php81/php-cgi.exe
7070<FilesMatch "\.php$">
71 AllowOverride None71 SetHandler application/x-httpd-php-cgi
72 Options None72</FilesMatch>
73 Require all denied73
74 74...
75 Require all granted75```
7676
77 77**C:\xampp\conf\httpd.conf:**
7878
7979```conf
8080# Include Virtualhosts
81# Default PHP Handler81Include "conf/vhosts/*.conf"
8282```
83Action application/x-httpd-php-cgi /php81/php-cgi.exe 83
8484**C:\xampp\conf\vhosts\litecart.local.conf:**
85 SetHandler application/x-httpd-php-cgi85
8686```conf
8787# Define the main domain
8888<VirtualHost *:80>
89...89 ServerName litecart.local
9090 DocumentRoot "D:\Clients\TiM International\LiteCart\repository (dev)\public_html"
91```conf C:\xampp\conf\httpd.conf91 <Directory "D:\Clients\TiM International\LiteCart\repository (dev)\public_html">
9292 Options Indexes FollowSymLinks Includes ExecCGI
93# Include Virtualhosts93 DirectoryIndex index.php index.html
9494 AllowOverride All
95Include "conf/vhosts/*.conf" 95
9696 <IfModule mod_authz_core.c>
97```conf C:\xampp\conf\vhosts\litecart.local.conf97 <RequireAny>
9898 Require ip 127.0.0.1
99# Define the main domain99 Require ip ::1
100100 </RequireAny>
101101 </IfModule>
102102
103 ServerName litecart.local103 </Directory>
104 DocumentRoot "D:\Clients\TiM International\LiteCart\repository (dev)\public_html"104</VirtualHost>
105 105
106 Options Indexes FollowSymLinks Includes ExecCGI106# Load the macro module for repetitive directives
107 DirectoryIndex index.php index.html107LoadModule macro_module modules/mod_macro.so
108 AllowOverride All108
109109#Define the macro
110 110<Macro VHostPHP $version>
111111 <VirtualHost *:80>
112 112 ServerName php$version.litecart.local
113 Require ip 127.0.0.1113 DocumentRoot "X:\Projects\LiteCart\public_html"
114 Require ip ::1114 <Directory "X:\Projects\LiteCart\public_html">
115115 Options Indexes FollowSymLinks Includes ExecCGI
116 116 DirectoryIndex index.php index.html
117117 AllowOverride All
118 118
119119 <IfModule mod_authz_core.c>
120 120 <RequireAny>
121121 Require ip 127.0.0.1
122122 Require ip ::1
123123 </RequireAny>
124# Load the macro module for repetitive directives124 </IfModule>
125125 </Directory>
126LoadModule macro_module modules/mod_macro.so126
127127 <FilesMatch "\.php$">
128# Define the macro128 SetHandler application/x-httpd-php$version-cgi
129129 </FilesMatch>
130130 </VirtualHost>
131131</Macro>
132 132
133 ServerName php$version.litecart.local133# Run the macro for each PHP version
134 DocumentRoot "X:\Projects\LiteCart\public_html"134Use VHostPHP 74
135 135Use VHostPHP 80
136 Options Indexes FollowSymLinks Includes ExecCGI136Use VHostPHP 81
137 DirectoryIndex index.php index.html137Use VHostPHP 82
138 AllowOverride All138
139139UndefMacro VHostPHP
140 140```
141141
142 142Alternatively, if you don't want to use Macros and rather define each and every subdomain:
143 Require ip 127.0.0.1143
144 Require ip ::1144**C:\xampp\conf\vhosts\litecart.local.conf:**
145145```conf
146 146<VirtualHost *:80>
147147 ServerName litecart.local
148 148 DocumentRoot "X:\Projects\LiteCart\public_html"
149149
150 150 <Directory "X:\Projects\LiteCart\public_html">
151151 Options Indexes FollowSymLinks Includes ExecCGI
152 152 DirectoryIndex index.php index.html
153 SetHandler application/x-httpd-php$version-cgi153 AllowOverride All
154154
155 155 <IfModule mod_authz_core.c>
156156 <RequireAny>
157 157 Require ip 127.0.0.1
158158 Require ip ::1
159159 </RequireAny>
160160 </IfModule>
161# Run the macro for each PHP version161 </Directory>
162162</VirtualHost>
163Use VHostPHP 74 Use VHostPHP 80 Use VHostPHP 81 Use VHostPHP 82163
164164<VirtualHost *:80>
165UndefMacro VHostPHP 165 ServerName php74.litecart.local
166166 DocumentRoot "X:\Projects\LiteCart\public_html"
167Alternatively, if you don't want to use Macros and rather define each167
168and every subdomain:168 <Directory "X:\Projects\LiteCart\public_html">
169169 Options Indexes FollowSymLinks Includes ExecCGI
170```conf C:\xampp\conf\vhosts\litecart.local.conf 170 DirectoryIndex index.php index.html
171171 AllowOverride All
172 ServerName litecart.local172
173 DocumentRoot "X:\Projects\LiteCart\public_html"173 <IfModule mod_authz_core.c>
174 174 <RequireAny>
175 175 Require ip 127.0.0.1
176 Options Indexes FollowSymLinks Includes ExecCGI176 Require ip ::1
177 DirectoryIndex index.php index.html177 </RequireAny>
178 AllowOverride All178 </IfModule>
179179
180 180 <FilesMatch "\.php$">
181181 SetHandler application/x-httpd-php74-cgi
182 182 </FilesMatch>
183 Require ip 127.0.0.1183
184 Require ip ::1184 </Directory>
185185</VirtualHost>
186 186
187187<VirtualHost *:80>
188 188 ServerName php80.litecart.local
189189 DocumentRoot "X:\Projects\LiteCart\public_html"
190 190
191191 <Directory "X:\Projects\LiteCart\public_html">
192192 Options Indexes FollowSymLinks Includes ExecCGI
193193 DirectoryIndex index.php index.html
194194 AllowOverride All
195195
196 ServerName php74.litecart.local196 <IfModule mod_authz_core.c>
197 DocumentRoot "X:\Projects\LiteCart\public_html"197 <RequireAny>
198 198 Require ip 127.0.0.1
199 199 Require ip ::1
200 Options Indexes FollowSymLinks Includes ExecCGI200 </RequireAny>
201 DirectoryIndex index.php index.html201 </IfModule>
202 AllowOverride All202
203203 <FilesMatch "\.php$">
204 204 SetHandler application/x-httpd-php80-cgi
205205 </FilesMatch>
206 206
207 Require ip 127.0.0.1207 </Directory>
208 Require ip ::1208</VirtualHost>
209209
210 210# And so on ...
211211```
212 212
213 213**C:\Windows\System32\drivers\etc\hosts:**
214 214```txt
215 SetHandler application/x-httpd-php74-cgi215127.0.0.1 litecart.local
216216127.0.0.1 php74.litecart.local
217 217127.0.0.1 php80.litecart.local
218 218127.0.0.1 php81.litecart.local
219219127.0.0.1 php82.litecart.local
220 220```
221
222
223
224
225
226 ServerName php80.litecart.local
227 DocumentRoot "X:\Projects\LiteCart\public_html"
228
229
230 Options Indexes FollowSymLinks Includes ExecCGI
231 DirectoryIndex index.php index.html
232 AllowOverride All
233
234
235
236
237 Require ip 127.0.0.1
238 Require ip ::1
239
240
241
242
243
244
245 SetHandler application/x-httpd-php80-cgi
246
247
248
249
250
251
252
253
254# And so on ...
255
256```txt C:\Windows\System32\drivers\etc\hosts 127.0.0.1
257litecart.local 127.0.0.1 php74.litecart.local 127.0.0.1
258php80.litecart.local 127.0.0.1 php81.litecart.local 127.0.0.1
259php82.litecart.local

Επεξεργάστηκε από tim στις 9 Ιαν 2024 και 22:24

This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.