Xampp and php files

Newbie here. Just installed xampp. I was attempting to run a file with .php extension and print some text on the screen. When I try to run the file instead of displaying the text the browser downloads a copy of the file into my Downloads folder. I suspect that this is a basic configuration issue but I don’t know how to fix it.

The causes of this error can be bad XAMPP configuration (Apache and/or PHP); or bad location of your php file.

PHP (or HTML) files must go in a specific directory, which must be in the apache configuration.

To know if XAMPP is working correctly, you must launch xampp.
Then, to know if it works correctly, enter http://localhost in your internet browser

For XAMPP configuration see the this forum: Apache Friends Support Forum • Index page

You have to make changes to /etc/apache2/https.conf AFAIK. It worked for me on Termux. Haven’t tried it on Manjaro yet.
Try adding this to httpd.conf

Addtype application/x-httpd-php

This also worked for me.

#Custom by Me

<IfModule php7_module>

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

    <IfModule dir_module>
        DirectoryIndex index.html index.php


Specifically, all the files you want to run must be in the XAMPP webroot, which is /opt/lampp/htdocs by default. XAMPP cannot see files that are outside of this directory, unless you tell it to (See Xampp page in Arch linux wiki)

1 Like