Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAMP 3, .htaccess and php_value

Hy

I've updated my mamp2 to 3. after that i'll get the following error in apache (2.2.5)

[Wed Mar 12 09:10:58 2014] [notice] Digest: generating secret for digest authentication ...
[Wed Mar 12 09:10:58 2014] [notice] FastCGI: process manager initialized (pid 13431)
[Wed Mar 12 09:10:58 2014] [notice] Digest: done
[Wed Mar 12 09:10:58 2014] [notice] Apache/2.2.25 (Unix) mod_wsgi/3.4 Python/2.7.5 mod_fastcgi/2.4.6 mod_ssl/2.2.25 OpenSSL/0.9.8y DAV/2 mod_perl/2.0.8 Perl/v5.18.0 configured -- resuming normal operations
[Wed Mar 12 09:11:07 2014] [alert] [client 10.241.101.148] /Applications/MAMP/htdocs/dev/application/sites/mypage/public_html/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

apache 2.2.5 / php version: 5.3.14

htaccess

php_value   xdebug.profiler_enable_trigger  1
php_value   html_errors On
php_value   xdebug.scream 0

php_value   display_errors  on
php_value   error_reporting 1023

php_value   xdebug.max_nesting_level 150

php_value   upload_max_filesize 70M
php_value   post_max_size 75M

AddType text/x-component .htc
AddType application/vnd.ms-fontobject eot
AddType font/opentype otf
AddType font/truetype ttf
AddType application/x-font-woff woff

php_value   newrelic.appname                                "myapp.ch.dev"
php_flag    newrelic.enabled                                on
php_flag    newrelic.browser_monitoring.auto_instrument     off

some ideas? i'm not that fit in apache configs. thanks

like image 769
roman Avatar asked Mar 12 '14 09:03

roman


People also ask

Is it possible to override PHP settings in a htaccess file?

In fact, modifying php.ini is actually more flexible than using php_value or php_flag: there are many things you can't override using .htaccess files, but you can override almost any PHP setting in the php.ini file. See our PHP support page for instructions on modifying php.ini.

Can I use PHP_value or PHP_flag commands in htaccess files?

Some PHP scripts suggest using " php_value " or " php_flag " commands in .htaccess files, as in this example: However, our servers run PHP in "CGI mode" as recommended by the PHP developers (not as an Apache module), so you can't use "php_value" or "php_flag" commands in .htaccess files.

How to fix HTTP error 500 in MAMP?

To troubleshoot and fix an HTTP Error 500 in MAMP, you can try the following steps: Check MAMP’s error log and resolve any code problems that appear. Generate a fresh .htaccess file. Deactivate all of your WordPress plugins and test each one for problems.

What are the common causes of errors on MAMP?

Another possible source specific to errors on MAMP comes into play when your site encounters a PHP fatal error. This is often the result of misconfigured files or incorrect code. In these cases, checking the PHP error logs for your installation will often reveal the file that’s causing the issue, as well as the specific problem with the code.


2 Answers

php_value and php_flag aren't allowed directives in your .htaccess file if you're running MAMP's php in CGI mode.

Assuming you're using MAMP Pro, go to the Main MAMP window's PHP tab and make sure that "Mode" is set to "Identical PHP version for all hosts (module)". Restart your MAMP server and your .htaccess overrides should be ok.

If you must run PHP in CGI mode, you can put the overrides directly into your php.ini file instead.

like image 98
r.aubin Avatar answered Sep 30 '22 20:09

r.aubin


If you can use php_value on all other servers except your local one and you really want to use PHP in CGI mode (as it was in my case), you can locally use php.ini file and add special condition inside your .htaccess file to keep it in repository etc. while still avoiding 500s.

For instance by using this snippet of code:

<IfModule mod_php5.c>
    php_value upload_max_filesize 200M
    php_value post_max_size 200M
</IfModule>

you use php_value only when it's possible (PHP as a module).

like image 29
Tomasz Racia Avatar answered Sep 30 '22 21:09

Tomasz Racia