PHP Files Are Downloaded by Browser Instead of Processed by Local Dev Server (Mamp)

PHP files are downloaded by browser instead of processed by local dev server (MAMP)

You are applying a mimetype where a handler should be (see documentation on handlers)

Try this instead:

AddType application/x-httpd-php5 .php

EDIT:
As you have indicated caching modules are loaded, you could read up on caching and htcacheclean (to clear the disk cache). You can also temporarily use the CacheDisable directive. One other thing that you could also try is to rename the file that you have requested (e.g. index.php -> index.bak), request the file again in the browser (should now 404), then revert and try again.

Apache is downloading php files instead of displaying them

The correct AddType for php is application/x-httpd-php

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

Also make sure your php module is loaded

LoadModule php5_module        modules/mod_php55.so

When you're configuring apache then try to view the page from another browser - I've had days when chrome stubbornly caches the result and it keeps downloading the source code while in another browser it's just fine.

PHP files are downloaded by browser instead of processed by local dev server (MAMP)

You are applying a mimetype where a handler should be (see documentation on handlers)

Try this instead:

AddType application/x-httpd-php5 .php

EDIT:
As you have indicated caching modules are loaded, you could read up on caching and htcacheclean (to clear the disk cache). You can also temporarily use the CacheDisable directive. One other thing that you could also try is to rename the file that you have requested (e.g. index.php -> index.bak), request the file again in the browser (should now 404), then revert and try again.

Apache is downloading php files instead of execute them

You should not set the Content-Type to application/x-httpd-php.

Instead, remove that header.

And use this:

AddHandler application/x-httpd-php .php

If you use PHP-FPM. then let me know, because the above won't work for PHP-FPM.

Edit:

Remove:

AddType application/x-httpd-php .php

Or change it to:

AddType text/html .php

The problem is:

  • application/x-httpd-php is not a MIME type, but rather a handler. That means your directive must be AddHandler instead of AddType

server path for mamp local server

After a bit of trail and error i found the solution, you need to set the server path to the location of mamp so you for the above examples you would write -

/Applications/MAMP/htdocs/140dev/db/

and

http://localhost:8888/140dev/ 

Apache shows PHP code instead of executing it

You must enable php! Check the folder mods-enabled in the Apache directory (default: /etc/apache2/) to see if you find a file named php. I don't remember the extension but I think it's .so.

Also check in /var/log/apache2/error.log to see if you have any other errors.



Related Topics



Leave a reply



Submit