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 beAddHandler
instead ofAddType
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
PHP Function Imagettftext() and Unicode
Unsetting Array Values in a Foreach Loop
Invoke External Shell Script from PHP and Get Its Process Id
Laravel 5.5 Error Base Table or View Already Exists: 1050 Table 'Users' Already Exists
Pdo Returning Incorrect, But Duplicate, Data. Key's Not in Database
Convert Clickable Anchor Tags to Plain Text in HTML Document
What Is the Most Secure Method for Uploading a File
Use of Initialization Vector in Openssl_Encrypt
PHP 7 Rc3: How to Install Missing MySQL Pdo
Getting Multiple Checkboxes Names/Id's with PHP
Phpmailer - the Following Smtp Error: Data Not Accepted
%2F in Url Breaks and Does Not Reference to the .PHP File Required
Why Is Calling a Function (Such as Strlen, Count etc) on a Referenced Value So Slow
PHP Warning: Exec() Unable to Fork
File_Get_HTML Displays Fatal Error Call to Undefined Function