Solved

php.ini

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

830 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