Is it possible to copy an existing php directory to laragon/bin/php to get an extra php version?


  • | 167 points

    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


  • | 9898 points

    Yes, see [Tutorial] How to add another PHP version (PHP 7.4 - PHP 8.0) - Updated

    If you want PHP8, check the work around on page 4 and 5.


  • | 167 points

    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.


  • | 9898 points

    @mgomez-tubs yes, that is the same process as PHP 8 for Apache, you need to copy the PHP7 ini and change gd2 to gd. See the details here: Don't support PHP8?#4


  • | 3469 points

    @mgomez-tubs other way is this:

    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 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\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.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-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:

    <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>
    

    Modified:

    <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 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': Bad
    header

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

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

    kdsjgkjgf


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.