leokhoa / laragon

Laragon is a portable, isolated, fast & powerful universal development environment for PHP, Node.js, Python, Java, Go, Ruby. It is fast, lightweight, easy-to-use and easy-to-extend.
https://laragon.org
4.47k stars 372 forks source link

AddHandler causing download file in Localhost/Laragon #538

Open cacacobra opened 1 year ago

cacacobra commented 1 year ago

On my cPanel Server it includes the code below in my htaccess, so when i run my system in Laragon/Localhost it causes download file index.

Is there any way to avoid this without changing the htaccess?

Inside Apache configs maybe?

# php -- BEGIN cPanel-generated handler, do not edit # Defina o pacote “ea-php70” como a linguagem padrão de programação “PHP”.

AddHandler application/x-httpd-ea-php70 .php .php7 .phtml

# php -- END cPanel-generated handler, do not edit

RobiNN1 commented 1 year ago

I don't think it can be fixed without changing. It downloads file because x-httpd-ea-php70 doesn't exist in laragon.

cacacobra commented 1 year ago

I don't think it can be fixed without changing. It downloads file because x-httpd-ea-php70 doesn't exist in laragon.

Is there any possibility to configure Laragon to accept it?

RobiNN1 commented 1 year ago

I remembered small trick I've used for php per project setup, it will add that missing handler, so you don't have to change .htaccess. Try this:

Add this to the end of your apache config before IncludeOptional ..., in my case it's C:/laragon/bin/apache/httpd-2.4.41-win64-VC14/conf/httpd.conf

And of course set correct path to the your php

ScriptAlias /php70 "C:/laragon/bin/php/php-7.0.33-Win32-VC14-x64"
Action application/x-httpd-ea-php70 /php70/php-cgi.exe
<Directory "C:/laragon/bin/php/php-7.0.33-Win32-VC14-x64">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>