Solved

php.ini

Posted on 2013-10-23
3
1,176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 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