1. Home
  2. VPS
  3. Configure php version in httpd-vhosts.conf (Virtual Host ...

Configure php version in httpd-vhosts.conf (Virtual Host ...

Rsdaa 31/10/2021 101

I have already solved it, as follows:

Following this post from the site in English to XAMPP:https://stackoverflow.com/a/49586592/4717133

And My Spanish POST:https://es.stackoverflow.com/a/432920/46896

With some changes to make it work onLaragon.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\php ewhere we place them, we must place ourselves a friendly name such as:\php70\ o \php72\ o \php74\ whatever the scenario; Very important we must verify that each version has the file php-cgi.exe since some old versions of php did not incorporate it; and this is a requirement.

Step 2: Configure php.ini

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.ini-development to php.ini and 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.conf for 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.exeAllowOverride NoneOptions NoneRequire all deniedRequire all granted# Example for php 7.4:ScriptAlias /php74 "C:/laragon/bin/php/php74"Action application/x-httpd-php74-cgi /php74/php-cgi.exeAllowOverride NoneOptions NoneRequire all deniedRequire all granted

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-enabled which 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:

Original:

DocumentRoot "C:/laragon/www/prueba/"ServerName prueba.meServerAlias *.prueba.meAllowOverride AllRequire all granted

Modified:

DocumentRoot "C:/laragon/www/prueba/"ServerName prueba.meServerAlias *.prueba.meAllowOverride AllRequire all grantedSetHandler application/x-httpd-php72-cgi#SetHandler application/x-httpd-php74-cgi

where the defined SetHandler will 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': Badheader

no need to define, modify or use the runtime environment variable:

SetEnv PHPRC "\\ruta\\a\\php\\"

kdsjgkjgf


PREV: Unable to Contact DHCP Server | DHCP Troubleshooting

NEXT: How to Troubleshoot the "Unable to Contact your DHCP Server ...

Popular Articles

Hot Articles
Back to Top