Solved

php.ini

Posted on 2013-10-23
3
1,165 Views
Last Modified: 2013-10-23
If you have subfolders on your website & you want a different php.ini to be in effect for scripts running in that subfolder, can you just put a version of php.ini in the specific subfolder & that will override the one at the root?

Specifically, if you have www.xyz.com/test, can you put a php.ini in test  & it's settings will override those at the root?

If not, how can that effect be accomplished?

Thanks
0
Comment
Question by:Richard Korts
  • 2
3 Comments
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 200 total points
Comment Utility
The answer is probably not.  The hosts that do allow you to use your own 'php.ini' have always specified that it be in the root of your hosting, at least the ones that I have seen.  You can put some directives in your .htaccess file in a subdirectory and you can put some in an include file in those subdirectories.

The problem is that 'php.ini' has to be read before your PHP code is read because it sets up the conditions under which PHP runs.  Some directives have to be set before PHP runs and can't be modified while it is running.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
More specific info here: http://php.net/manual/en/ini.php
0
 
LVL 1

Accepted Solution

by:
itusedtobe earned 300 total points
Comment Utility
In a standard server configuration there is a global php.ini (for instance in /etc/php/). Loaded configuration file is visible when calling <?php phpinfo(); ?> script.

You can do overrides in a couple of ways - depends on server and configuration. Two potential ways may be:

1. .htaccess file (if Apache's config allows “AllowOverride Options” or “AllowOverride All” )
Just place a .htaccess file in the subdirectory and add options:
php_flag <boolean-flag-name> on|off
php_value <flag-name> <flag-value>
For example:
php_value upload_max_filesize 50M

2. Directly in your php scripts via ini_set
<?php
ini_set('upload_max_filesize', '50M');
?>
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now