Is it possible to copy an existing php directory to laragon/bin/php to get an extra php version?
I assumed it would work, and it does except when the php.ini file gets misteriously removed after pressing Start All.... is there something I can do to prevent that? If i replace the php.ini after "Star All" it will does work fine.
BTW Im using the portable Laragon installation
If you want PHP8, check the work around on page 4 and 5.
Thanks and sorry for the duplicate answer. I searched in that thread but couldn't really find much about migrating an existing PHP installation. Also they are using Apache as webserver, and since I have the portable Laragon I have Nginx, and its logs weren't really that useful.
I ended up using a fresh download of PHP (php-7.4.15-nts-Win32-vc15-x64) and moving my extensions manually. The php.ini was then automatically created by laragon.
@mgomez-tubs other way is this:
I have already solved it, as follows:
Following this post from the site in English to XAMPP:
And My Spanish POST:
With some changes to make it work on Laragon.
The PHP NTS (non thread safe) versions are NOT compatible with Laragon.
Step 1: Download PHP
Download the versions of PHP that we are going to use, and unzip them and take them to the php directory in Laragon:
C:\laragon\bin\phpewhere we place them, we must place ourselves a friendly name such as:
\php74\whatever the scenario; Very important we must verify that each version has the file
php-cgi.exesince some old versions of php did not incorporate it; and this is a requirement.
Step 2: Configure
In each version of php that we will use we must go to the file
C:\laragon\bin\php\php##\php.ini(where ## is the version of php) in a code or text editor. If the file does not exist, copy
php.iniand open it. Then we will find and uncomment the following line:
extension_dir = "ext"
and we will modify it:
extension_dir = "C:/laragon/bin/php/php72/ext"
with this we will make sure that php points to the correct directory of its extensions.
Step 3: Configure apache
go directly to the apache configuration directory:
C:\laragon\bin\apache\httpd-2.4.35-win64-VC15\conf(it may vary depending on the version of apache used) and open with a code or text editor the file
httpd.conffor each version of php that we want to use we must create an http alias and execute the corresponding php-cgi, this must be placed at the end of the file:
# Example for php 7.2: ScriptAlias /php72 "C:/laragon/bin/php/php72" Action application/x-httpd-php72-cgi /php72/php-cgi.exe <Directory "C:/laragon/bin/php/php72"> AllowOverride None Options None Require all denied <Files "php-cgi.exe"> Require all granted </Files> </Directory> # Example for php 7.4: ScriptAlias /php74 "C:/laragon/bin/php/php74" Action application/x-httpd-php74-cgi /php74/php-cgi.exe <Directory "C:/laragon/bin/php/php74"> AllowOverride None Options None Require all denied <Files "php-cgi.exe"> Require all granted </Files> </Directory>
Note: You can add more versions of PHP to your Paragon installation by following steps 1-3 if you wish.
Step 4: Configure Virtual Host
We must go to the directory:
C:\laragon\etc\apache2\sites-enabledwhich is the place where Laragon has the Virtual Host configuration files; Depending on which projects we have, we must open each configuration file with a code or text editor:
<VirtualHost *:80> DocumentRoot "C:/laragon/www/prueba/" ServerName prueba.me ServerAlias *.prueba.me <Directory "C:/laragon/www/prueba/"> AllowOverride All Require all granted </Directory> </VirtualHost>
<VirtualHost *:80> DocumentRoot "C:/laragon/www/prueba/" ServerName prueba.me ServerAlias *.prueba.me <Directory "C:/laragon/www/prueba/"> AllowOverride All Require all granted </Directory> <FilesMatch "\.php$"> SetHandler application/x-httpd-php72-cgi #SetHandler application/x-httpd-php74-cgi </FilesMatch> </VirtualHost>
where the defined
SetHandlerwill refer to the Alias to use.
and We finish by restarting the web services or the computer.
I did not find or get the error:
Update for Error: malformed header from script 'php-cgi.exe': Bad
no need to define, modify or use the runtime environment variable:
SetEnv PHPRC "\\ruta\\a\\php\\"