Solved

php.ini

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

690 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