Solved

php.ini

Posted on 2013-10-23
3
1,167 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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 200 total points
ID: 39595769
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 83

Expert Comment

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

Accepted Solution

by:
itusedtobe earned 300 total points
ID: 39595808
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to dynamically set the form action using jQuery.

911 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

25 Experts available now in Live!

Get 1:1 Help Now