├── README.md
└── apache
└── conf
├── php.d
├── multi-php-versions.conf
├── php_cgi.conf
└── vars.conf
└── vhost
└── localhost.conf
/README.md:
--------------------------------------------------------------------------------
1 | ### Reason
2 | I and a lot developer work with multiple project at same time, sometimes we are need working with multiple php version
3 | at same time. We don't want to run multiple XAMPP with different ports. So i created this project to help anybody need
4 | to run multiple php version at same times with only 1 XAMPP
5 |
6 | ### How it work?
7 | XAMPP use `mod_php` to run php, that mean you only work with 1 php version with xampp. To resolve this, i use `mod_fcgi`
8 | instead `mod_php`. With `mod_fcgi` we can redirect request to correctly php version we want.
9 |
10 | ### Install on window
11 | 1. Download XAMPP. this guide use [XAMPP 7.2.5 x86](https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/7.2.5/xampp-win32-7.2.5-0-VC15-installer.exe/download)
12 | 2. Download [mod_fcgi](https://www.apachelounge.com/download/) . `XAMPP 7.2.5 x86` use `Apache/2.4.33 (Win32)`, so i will download [mod_fcgid-2.3.9-win32-VC15](https://www.apachelounge.com/download/VC15/modules/mod_fcgid-2.3.9-win32-VC15.zip)
13 | 3. Install XAMPP. for example i installed to `C:/xampp`. Extract `mod_fcgid-2.3.9-win32-VC15.zip` and copy file `mod_fcgid.so` to `C:/xampp/apache/modules`
14 | 4. Download php version you want from[ https://windows.php.net/downloads/releases/archives/](https://windows.php.net/downloads/releases/archives/). Unzip this to folder `C:/xampp`. for example i will download [php-5.6.35-nts-Win32-VC11-x86](https://windows.php.net/downloads/releases/archives/php-5.6.35-nts-Win32-VC11-x86.zip) and unzip to `C:/xampp/php5635`. rename `php5635/php.ini-development` to `php5635/php.ini` and add this line to end of `php.ini`
15 | ```
16 | [custom_php_variable]
17 | extension_dir = "C:/xampp/php5635/ext/"
18 | session.save_path = "C:/xampp/tmp/"
19 | upload_tmp_dir = "C:/xampp/tmp/"
20 | sys_temp_dir = "C:/xampp/tmp/"
21 | soap.wsdl_cache_dir = "C:/xampp/tmp/"
22 | ```
23 | 5. Copy directory [apache](https://github.com/hugdx/multiple-php-version-with-xampp/tree/master/apache) to `C:/xampp/apache` and edit file `C:/xampp/apache/conf/php.d/vars.conf`
24 | ```
25 | # Change this to your xampp on your computer. for this example, it is C:/xampp
26 | Define XAMPP_DIR "C:/xampp"
27 |
28 | # In step #4, i downloaded php 5.6.35, i will add path to here
29 | Define PHP_56_CGI "${XAMPP_DIR}/php5635/php-cgi.exe"
30 | Define PHP_56_RC "${XAMPP_DIR}/php5635/"
31 |
32 | # If you download more php versions, just add more lines here, for example php 5.6.30
33 | # Define PHP_5630_CGI "${XAMPP_DIR}/php5630/php-cgi.exe"
34 | # Define PHP_5630_RC "${XAMPP_DIR}/php5630/"
35 |
36 | # The default php version of XAMPP 7.2.5 x86 is php 7.2.5
37 | Define PHP_72_CGI "${XAMPP_DIR}/php/php-cgi.exe"
38 | Define PHP_72_RC "${XAMPP_DIR}/php"
39 |
40 | # This will set default php version when run with xampp
41 | Define PHP_CGI ${PHP_72_CGI}
42 | Define PHP_RC ${PHP_72_RC}
43 | ```
44 | 6. Edit file `C:/xampp/apache/conf/extra/httpd-xampp.conf`.
45 | Comment lines and add more 1 line `Include "conf/php.d/multi-php-versions.conf"`
46 | ```
47 | #
48 | # PHP-Module setup
49 | #
50 | #LoadFile "C:/xampp/php/php7ts.dll"
51 | #LoadFile "C:/xampp/php/libpq.dll"
52 | #LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
53 |
54 | #
55 | # SetHandler application/x-httpd-php
56 | #
57 | #
58 | # SetHandler application/x-httpd-php-source
59 | #
60 |
61 | #
62 | # PHP-CGI setup
63 | #
64 | #
65 | # SetHandler application/x-httpd-php-cgi
66 | #
67 | #
68 | # Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
69 | #
70 |
71 | # Load php multiple versions config
72 | Include "conf/php.d/multi-php-versions.conf"
73 | ```
74 |
75 | 7. Create your project with vhost: for example i will create project `php-multiple-version` with `php 5.6` and `php 7.2`
76 | Create vhost file `C:/xampp/apache/conf/vhost/php72-php-multiple-version.local.conf`
77 | ```
78 |
79 | ServerAdmin webmaster@admin.local
80 | DocumentRoot "C:/Projects/php-multiple-version/"
81 | ServerName php72-php-multiple-version.local
82 | ErrorLog "logs/php72-php-multiple-version.local-error.log"
83 | CustomLog "logs/php72-php-multiple-version.local.log" common
84 |
85 | FcgidInitialEnv PHPRC ${PHP_72_RC}
86 |
87 | Define PHP_CGI ${PHP_71_CGI}
88 | Include "conf/php.d/php_cgi.conf"
89 |
90 |
91 | ```
92 |
93 | Create vhost file `C:/xampp/apache/conf/vhost/php56-php-multiple-version.local.conf`
94 | ```
95 |
96 | ServerAdmin webmaster@admin.local
97 | DocumentRoot "C:/Projects/php-multiple-version/"
98 | ServerName php56-php-multiple-version.local
99 | ErrorLog "logs/php56-php-multiple-version.local-error.log"
100 | CustomLog "logs/php56-php-multiple-version.local.log" common
101 |
102 | FcgidInitialEnv PHPRC ${PHP_56_RC}
103 |
104 | Define PHP_CGI ${PHP_56_CGI}
105 | Include "conf/php.d/php_cgi.conf"
106 |
107 |
108 | ```
109 |
110 | add to end of file `C:\Windows\System32\drivers\etc\hosts`
111 | ```
112 | 127.0.0.1 php72-php-multiple-version.local
113 | 127.0.0.1 php56-php-multiple-version.local
114 | ```
115 |
116 | create file `C:/Projects/php-multiple-version/index.php`
117 | ```php
118 |
5 | FcgidInitialEnv OPENSSL_CONF ${OPENSSL_CONF}
6 | FcgidInitialEnv PHPRC ${PHP_RC}
7 | FcgidInitialEnv PHP_PEAR_SYSCONF_DIR ${PHP_PEAR_DIR}
8 |
9 | FcgidInitialEnv MYSQL_HOME ${MYSQL_HOME}
10 | FcgidInitialEnv TMP ${TMP_DIR}
11 | FcgidInitialEnv TEMP ${TMP_DIR}
12 | SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
13 |
14 | FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
15 |
16 | FcgidIOTimeout 1200
17 | FcgidConnectTimeout 1200
18 | FcgidBusyScanInterval 1200
19 | FcgidBusyTimeout 1200
20 | FcgidErrorScanInterval 1200
21 | FcgidIdleScanInterval 1200
22 | FcgidIdleTimeout 1200
23 | FcgidProcessLifeTime 3600
24 | FcgidZombieScanInterval 1200
25 | FcgidMaxRequestLen 104857600000
26 |
27 |
28 | SetHandler fcgid-script
29 | Options Indexes FollowSymLinks ExecCGI
30 | FcgidWrapper ${PHP_CGI} .php
31 |
32 |
33 |
34 |
35 | AddType application/x-httpd-php .phps
36 | AddType application/x-httpd-php .php3
37 |
38 |
39 | Include "conf/vhost/localhost.conf"
40 | Include "conf/vhost/*.conf"
--------------------------------------------------------------------------------
/apache/conf/php.d/php_cgi.conf:
--------------------------------------------------------------------------------
1 | Options +ExecCGI
2 | AllowOverride All
3 | order allow,deny
4 | allow from all
5 | deny from none
6 | Require all granted
7 |
8 | FcgidWrapper ${PHP_CGI} .php
9 |
--------------------------------------------------------------------------------
/apache/conf/php.d/vars.conf:
--------------------------------------------------------------------------------
1 | # global variables
2 | Define XAMPP_DIR "C:/xampp"
3 | Define OPENSSL_CONF "${XAMPP_DIR}/apache/bin/openssl.cnf"
4 | Define PHP_PEAR_DIR "\\xampp\\php"
5 | Define MYSQL_HOME "\\xampp\\mysql\\bin"
6 | Define TMP_DIR "\\xampp\\tmp"
7 |
8 | # define variables for php 5.6
9 | #Define PHP_56_CGI "${XAMPP_DIR}/php5635/php-cgi.exe"
10 | #Define PHP_56_RC "${XAMPP_DIR}/php5635/"
11 |
12 | # define variables for php 7.1
13 | #Define PHP_71_CGI "${XAMPP_DIR}/php7116/php-cgi.exe"
14 | #Define PHP_71_RC "${XAMPP_DIR}/php7116"
15 |
16 | # define variables for php 7.2
17 | Define PHP_72_CGI "${XAMPP_DIR}/php/php-cgi.exe"
18 | Define PHP_72_RC "${XAMPP_DIR}/php"
19 |
20 | # define default php on xampp
21 | Define PHP_CGI ${PHP_72_CGI}
22 | Define PHP_RC ${PHP_72_RC}
--------------------------------------------------------------------------------
/apache/conf/vhost/localhost.conf:
--------------------------------------------------------------------------------
1 |
2 | ServerAdmin webmaster@local
3 | DocumentRoot "${XAMPP_DIR}/htdocs/"
4 | ServerName localhost
5 | ErrorLog "logs/localhost-error.log"
6 | CustomLog "logs/localhost.log" common
7 |
8 | FcgidInitialEnv PHPRC ${PHP_RC}
9 |
10 | Define PHP_CGI ${PHP_CGI}
11 | Include "conf/php.d/php_cgi.conf"
12 |
13 |
--------------------------------------------------------------------------------