.user.ini file only works 2 level of folder
Asked Answered
S

0

3

I have Apache with PHP installed (on Windows) and run as fastCGI.
My php.ini has this value, upload_max_filesize = 2M.

I override this value in .user.ini file to 10M.

Every thing works fine until the folder level is deeper than 2 level.
For example:
If I put .user.ini file into www root.
http://localhost/ -> ini_get('upload_max_filesize') result is 10M
http://localhost/test -> ini_get('upload_max_filesize') result is 10M
http://localhost/test/lv2 -> ini_get('upload_max_filesize') result is 10M
http://localhost/test/lv2/lv3 -> ini_get('upload_max_filesize') result becomes 2M which is php.ini value and this folder has no .user.ini file.
These are not in virtual directory.

How to make .user.ini file works in deeper level of folder?


edited: add httpd.conf for php

<IfModule fcgid_module>
    FcgidInitialEnv PHPRC "C:/wwwserver/php/php5.6"
    FcgidInitialEnv PATH "C:/wwwserver/php/php5.6;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files (x86)/ImageMagick-6.9.3-Q16;"
    FcgidInitialEnv SystemRoot "C:/Windows"
    FcgidInitialEnv SystemDrive "C:"
    FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
    FcgidInitialEnv TMP "C:/WINDOWS/Temp"
    FcgidInitialEnv windir "C:/WINDOWS"
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
    FcgidIOTimeout 64
    FcgidConnectTimeout 16
    FcgidMaxRequestsPerProcess 500
    FcgidMaxRequestLen 30000000

    <Files ~ "\.php$">
        AddHandler fcgid-script .php
        FcgidWrapper C:/wwwserver/php/php5.6/php-cgi.exe .php
    </Files>
</IfModule>

Reference: https://www.apachelounge.com/viewtopic.php?p=22141

Subtilize answered 13/1, 2017 at 6:19 Comment(6)
I had similar problems due to extra trailing slash in Apache config. It changed $_SERVER['SCRIPT_FILENAME'] which ultimately lead to freaky .user.ini behaviour. Check https://mcmap.net/q/1182541/-does-the-user-ini-file-work-for-subdirectoriesWheaten
@Wheaten But I'm on Windows.Subtilize
on windows, you can have this issue as well. check phpinfo and report back what does SCRIPT_FILENAME say.Wheaten
C:/Users/xxx/my-sites/info.php As I said and it seems nothing wrong. I don't think it is because slash in my case. And there is no extra slash in the configuration.Subtilize
I wonder if this happens on 7.0 on windows as well? It seem that there are some open issues with current implementation of php_cgi_ini_activate_user_config. they kinda explain your situation bugs.php.net/bug.php?id=69436. Also this, however I was unable to find specific bug fixes in bug track serverfault.com/questions/441855/custom-php-ini-files-for-iis7Wheaten
@Wheaten This was fixed since PHP 7.3.19 thanks. :-)Subtilize

© 2022 - 2024 — McMap. All rights reserved.