Run Multiple Php Versions Apache
Τίτλος
No changesPermalink
No changesΠεριεχόμενο
Old | New | ||
---|---|---|---|
1 | # How to run multiple PHP versions with Apache | 1 | # How to run multiple PHP versions with Apache |
2 | 2 | ||
3 | ```conf C:\xampp\conf\extra\httpd-xampp.conf | 3 | **C:\xampp\conf\extra\httpd-xampp.conf:** |
4 | 4 | ||
5 | # | 5 | ```conf |
6 | 2. XAMPP settings | 6 | # |
7 | 3. | 7 | # XAMPP settings |
8 | 8 | # | |
9 | 9 | ||
10 | 10 | <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" |
14 | 14 | </IfModule> | |
15 | 15 | ||
16 | 16 | # | |
17 | # | 17 | # PHP Setup |
18 | 2. PHP Setup | 18 | # |
19 | 3. | 19 | |
20 | 20 | # PHP 7.4 | |
21 | # PHP 7.4 | 21 | ScriptAlias /php74 "C:/xampp/php74" |
22 | 22 | Action application/x-httpd-php74-cgi /php74/php-cgi.exe | |
23 | ScriptAlias /php74 "C:/xampp/php74" Action | 23 | <Directory "C:/xampp/php74"> |
24 | application/x-httpd-php74-cgi /php74/php-cgi.exe | 24 | AllowOverride None |
25 | 25 | Options None | |
26 | AllowOverride None | 26 | Require all denied |
27 | Options None | 27 | <Files "php-cgi.exe"> |
28 | Require all denied | 28 | Require all granted |
29 | 29 | </Files> | |
30 | Require all granted | 30 | </Directory> |
31 | 31 | ||
32 | 32 | # PHP 8.0 | |
33 | 33 | ScriptAlias /php80 "C:/xampp/php80" | |
34 | 34 | Action application/x-httpd-php80-cgi /php80/php-cgi.exe | |
35 | 35 | <Directory "C:/xampp/php80"> | |
36 | # PHP 8.0 | 36 | AllowOverride None |
37 | 37 | Options None | |
38 | ScriptAlias /php80 "C:/xampp/php80" Action | 38 | Require all denied |
39 | application/x-httpd-php80-cgi /php80/php-cgi.exe | 39 | <Files "php-cgi.exe"> |
40 | 40 | Require all granted | |
41 | AllowOverride None | 41 | </Files> |
42 | Options None | 42 | </Directory> |
43 | Require all denied | 43 | |
44 | 44 | # PHP 8.1 | |
45 | Require all granted | 45 | ScriptAlias /php81 "C:/xampp/php81" |
46 | 46 | Action application/x-httpd-php81-cgi /php81/php-cgi.exe | |
47 | 47 | <Directory "C:/xampp/php81"> | |
48 | 48 | AllowOverride None | |
49 | 49 | Options None | |
50 | 50 | Require all denied | |
51 | # PHP 8.1 | 51 | <Files "php-cgi.exe"> |
52 | 52 | Require all granted | |
53 | ScriptAlias /php81 "C:/xampp/php81" Action | 53 | </Files> |
54 | application/x-httpd-php81-cgi /php81/php-cgi.exe | 54 | </Directory> |
55 | 55 | ||
56 | AllowOverride None | 56 | # PHP 8.2 |
57 | Options None | 57 | ScriptAlias /php82 "C:/xampp/php82" |
58 | Require all denied | 58 | Action application/x-httpd-php82-cgi /php82/php-cgi.exe |
59 | 59 | <Directory "C:/xampp/php82"> | |
60 | Require all granted | 60 | AllowOverride None |
61 | 61 | Options None | |
62 | 62 | Require all denied | |
63 | 63 | <Files "php-cgi.exe"> | |
64 | 64 | Require all granted | |
65 | 65 | </Files> | |
66 | # PHP 8.2 | 66 | </Directory> |
67 | 67 | ||
68 | ScriptAlias /php82 "C:/xampp/php82" Action | 68 | # Default PHP Handler |
69 | application/x-httpd-php82-cgi /php82/php-cgi.exe | 69 | Action application/x-httpd-php-cgi /php81/php-cgi.exe |
70 | 70 | <FilesMatch "\.php$"> | |
71 | AllowOverride None | 71 | SetHandler application/x-httpd-php-cgi |
72 | Options None | 72 | </FilesMatch> |
73 | Require all denied | 73 | |
74 | 74 | ... | |
75 | Require all granted | 75 | ``` |
76 | 76 | ||
77 | 77 | **C:\xampp\conf\httpd.conf:** | |
78 | 78 | ||
79 | 79 | ```conf | |
80 | 80 | # Include Virtualhosts | |
81 | # Default PHP Handler | 81 | Include "conf/vhosts/*.conf" |
82 | 82 | ``` | |
83 | Action application/x-httpd-php-cgi /php81/php-cgi.exe | 83 | |
84 | 84 | **C:\xampp\conf\vhosts\litecart.local.conf:** | |
85 | SetHandler application/x-httpd-php-cgi | 85 | |
86 | 86 | ```conf | |
87 | 87 | # Define the main domain | |
88 | 88 | <VirtualHost *:80> | |
89 | ... | 89 | ServerName litecart.local |
90 | 90 | DocumentRoot "D:\Clients\TiM International\LiteCart\repository (dev)\public_html" | |
91 | ```conf C:\xampp\conf\httpd.conf | 91 | <Directory "D:\Clients\TiM International\LiteCart\repository (dev)\public_html"> |
92 | 92 | Options Indexes FollowSymLinks Includes ExecCGI | |
93 | # Include Virtualhosts | 93 | DirectoryIndex index.php index.html |
94 | 94 | AllowOverride All | |
95 | Include "conf/vhosts/*.conf" | 95 | |
96 | 96 | <IfModule mod_authz_core.c> | |
97 | ```conf C:\xampp\conf\vhosts\litecart.local.conf | 97 | <RequireAny> |
98 | 98 | Require ip 127.0.0.1 | |
99 | # Define the main domain | 99 | Require ip ::1 |
100 | 100 | </RequireAny> | |
101 | 101 | </IfModule> | |
102 | 102 | ||
103 | ServerName litecart.local | 103 | </Directory> |
104 | DocumentRoot "D:\Clients\TiM International\LiteCart\repository (dev)\public_html" | 104 | </VirtualHost> |
105 | 105 | ||
106 | Options Indexes FollowSymLinks Includes ExecCGI | 106 | # Load the macro module for repetitive directives |
107 | DirectoryIndex index.php index.html | 107 | LoadModule macro_module modules/mod_macro.so |
108 | AllowOverride All | 108 | |
109 | 109 | #Define the macro | |
110 | 110 | <Macro VHostPHP $version> | |
111 | 111 | <VirtualHost *:80> | |
112 | 112 | ServerName php$version.litecart.local | |
113 | Require ip 127.0.0.1 | 113 | DocumentRoot "X:\Projects\LiteCart\public_html" |
114 | Require ip ::1 | 114 | <Directory "X:\Projects\LiteCart\public_html"> |
115 | 115 | Options Indexes FollowSymLinks Includes ExecCGI | |
116 | 116 | DirectoryIndex index.php index.html | |
117 | 117 | AllowOverride All | |
118 | 118 | ||
119 | 119 | <IfModule mod_authz_core.c> | |
120 | 120 | <RequireAny> | |
121 | 121 | Require ip 127.0.0.1 | |
122 | 122 | Require ip ::1 | |
123 | 123 | </RequireAny> | |
124 | # Load the macro module for repetitive directives | 124 | </IfModule> |
125 | 125 | </Directory> | |
126 | LoadModule macro_module modules/mod_macro.so | 126 | |
127 | 127 | <FilesMatch "\.php$"> | |
128 | # Define the macro | 128 | SetHandler application/x-httpd-php$version-cgi |
129 | 129 | </FilesMatch> | |
130 | 130 | </VirtualHost> | |
131 | 131 | </Macro> | |
132 | 132 | ||
133 | ServerName php$version.litecart.local | 133 | # Run the macro for each PHP version |
134 | DocumentRoot "X:\Projects\LiteCart\public_html" | 134 | Use VHostPHP 74 |
135 | 135 | Use VHostPHP 80 | |
136 | Options Indexes FollowSymLinks Includes ExecCGI | 136 | Use VHostPHP 81 |
137 | DirectoryIndex index.php index.html | 137 | Use VHostPHP 82 |
138 | AllowOverride All | 138 | |
139 | 139 | UndefMacro VHostPHP | |
140 | 140 | ``` | |
141 | 141 | ||
142 | 142 | Alternatively, if you don't want to use Macros and rather define each and every subdomain: | |
143 | Require ip 127.0.0.1 | 143 | |
144 | Require ip ::1 | 144 | **C:\xampp\conf\vhosts\litecart.local.conf:** |
145 | 145 | ```conf | |
146 | 146 | <VirtualHost *:80> | |
147 | 147 | ServerName litecart.local | |
148 | 148 | DocumentRoot "X:\Projects\LiteCart\public_html" | |
149 | 149 | ||
150 | 150 | <Directory "X:\Projects\LiteCart\public_html"> | |
151 | 151 | Options Indexes FollowSymLinks Includes ExecCGI | |
152 | 152 | DirectoryIndex index.php index.html | |
153 | SetHandler application/x-httpd-php$version-cgi | 153 | AllowOverride All |
154 | 154 | ||
155 | 155 | <IfModule mod_authz_core.c> | |
156 | 156 | <RequireAny> | |
157 | 157 | Require ip 127.0.0.1 | |
158 | 158 | Require ip ::1 | |
159 | 159 | </RequireAny> | |
160 | 160 | </IfModule> | |
161 | # Run the macro for each PHP version | 161 | </Directory> |
162 | 162 | </VirtualHost> | |
163 | Use VHostPHP 74 Use VHostPHP 80 Use VHostPHP 81 Use VHostPHP 82 | 163 | |
164 | 164 | <VirtualHost *:80> | |
165 | UndefMacro VHostPHP | 165 | ServerName php74.litecart.local |
166 | 166 | DocumentRoot "X:\Projects\LiteCart\public_html" | |
167 | Alternatively, if you don't want to use Macros and rather define each | 167 | |
168 | and every subdomain: | 168 | <Directory "X:\Projects\LiteCart\public_html"> |
169 | 169 | Options Indexes FollowSymLinks Includes ExecCGI | |
170 | ```conf C:\xampp\conf\vhosts\litecart.local.conf | 170 | DirectoryIndex index.php index.html |
171 | 171 | AllowOverride All | |
172 | ServerName litecart.local | 172 | |
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 ExecCGI | 176 | Require ip ::1 |
177 | DirectoryIndex index.php index.html | 177 | </RequireAny> |
178 | AllowOverride All | 178 | </IfModule> |
179 | 179 | ||
180 | 180 | <FilesMatch "\.php$"> | |
181 | 181 | SetHandler application/x-httpd-php74-cgi | |
182 | 182 | </FilesMatch> | |
183 | Require ip 127.0.0.1 | 183 | |
184 | Require ip ::1 | 184 | </Directory> |
185 | 185 | </VirtualHost> | |
186 | 186 | ||
187 | 187 | <VirtualHost *:80> | |
188 | 188 | ServerName php80.litecart.local | |
189 | 189 | DocumentRoot "X:\Projects\LiteCart\public_html" | |
190 | 190 | ||
191 | 191 | <Directory "X:\Projects\LiteCart\public_html"> | |
192 | 192 | Options Indexes FollowSymLinks Includes ExecCGI | |
193 | 193 | DirectoryIndex index.php index.html | |
194 | 194 | AllowOverride All | |
195 | 195 | ||
196 | ServerName php74.litecart.local | 196 | <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 ExecCGI | 200 | </RequireAny> |
201 | DirectoryIndex index.php index.html | 201 | </IfModule> |
202 | AllowOverride All | 202 | |
203 | 203 | <FilesMatch "\.php$"> | |
204 | 204 | SetHandler application/x-httpd-php80-cgi | |
205 | 205 | </FilesMatch> | |
206 | 206 | ||
207 | Require ip 127.0.0.1 | 207 | </Directory> |
208 | Require ip ::1 | 208 | </VirtualHost> |
209 | 209 | ||
210 | 210 | # And so on ... | |
211 | 211 | ``` | |
212 | 212 | ||
213 | 213 | **C:\Windows\System32\drivers\etc\hosts:** | |
214 | 214 | ```txt | |
215 | SetHandler application/x-httpd-php74-cgi | 215 | 127.0.0.1 litecart.local |
216 | 216 | 127.0.0.1 php74.litecart.local | |
217 | 217 | 127.0.0.1 php80.litecart.local | |
218 | 218 | 127.0.0.1 php81.litecart.local | |
219 | 219 | 127.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 | ||
257 | litecart.local 127.0.0.1 php74.litecart.local 127.0.0.1 | ||
258 | php80.litecart.local 127.0.0.1 php81.litecart.local 127.0.0.1 | ||
259 | php82.litecart.local |
Επεξεργάστηκε από tim στις 9 Ιαν 2024 και 22:24