php.ini configuration per user

Started by Administrator, October 25, 2014, 08:22:55 PM

Previous topic - Next topic

Administrator

you can make php.ini per user account,  user only needs is to create php.ini file and add values in it.

Location of the php.ini file is
/home/USERNAME/php.ini

How to test php.ini changes?
Simple create phpinfo.php file in the users public_html folder and add the following content in it.

Example location: /home/USERNAME/public_html/phpinfo.php
<?php
phpinfo
();
?>



Now open url in your browser (Apache restart is NOT needed):
http://your-domain.com/phpinfo.php



PHP.ini values
http://php.net/manual/en/ini.list.php

akmallinux

I change, in /home/username/public_html/php.ini
then i check with php.info, but the configuration not changed? how to fix it?

Administrator

have you checked in phpinfo() which php.ini path is loaded ?

akmallinux

Yes, the php path in my public html, http://domain.com/info.php, the configuration is loaded in here /home/shinoa/public_html/php.ini, i change upload max filesize , but when i login in wp-admin, i use wordpress, the configuration not change, upload file limit it's not change.

Administrator

Quote from: akmallinux on September 28, 2015, 08:44:26 AM
Yes, the php path in my public html, http://domain.com/info.php, the configuration is loaded in here /home/shinoa/public_html/php.ini, i change upload max filesize , but when i login in wp-admin, i use wordpress, the configuration not change, upload file limit it's not change.

to make this change for wp-admin folder you should add php.ini file in wp-admin folder.

akmallinux


monkeyking

Quote from: Administrator on September 28, 2015, 09:12:39 PM
to make this change for wp-admin folder you should add php.ini file in wp-admin folder.

This doesn't work in CWPpro version: 0.9.8.742. Is there another method?

monkeyking

php.ini doesn't work with php-fpm in CWPpro version: 0.9.8.741 and above. You have to change it.

from
php.ini
to
.user.ini

studio4host

with php-fpm you need to make a file named as ".user.ini"
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

venty

Quote from: monkeyking on December 03, 2018, 07:15:56 PM
php.ini doesn't work with php-fpm in CWPpro version: 0.9.8.741 and above. You have to change it.

from
php.ini
to
.user.ini

Is local php.ini  working for a user...?

GTMAN

On further research its was an Apache config error which apparently is quite common. Specifically it was a trailing slash error in the domain.ca.conf file.

/usr/local/apache/conf.d/vhosts

<IfModule proxy_fcgi_module>
<FilesMatch \.php$>
SetHandler "proxy:unix:/opt/alt/php-fpm73/usr/var/sockets/jet.sock|fcgi://localhost/"
</FilesMatch>



The trailing slash after localhost breaks the recursive search at least for ClassicPress / WordPress.



https://stackoverflow.com/questions/27226055/does-the-user-ini-file-work-for-subdirectories

slimtim

Hello,
I switched from php-cgi to php-fpm and it can't read .user.ini from /home/user but /home/user/public_html only, where is .user.ini public and mixed with another files. Is possible a manual or template config to have .user.ini working from /home/user directory? Thank you.

Orlox

I have the same issue. I am using this guide https://wiki.centos-webpanel.com/php-open_basedir but the per user does not work.

studio4host

NGINX + PHP-FPM
configuration files are:
/etc/nginx/conf.d/vhosts/DOMAIN.conf
/etc/nginx/conf.d/vhosts/DOMAIN.ssl.conf

under fastcgi_param add one more line and reload/restart nginx

fastcgi_param   PHP_ADMIN_VALUE "open_basedir =/home/USERNAME:/tmp:";

** Note that manual editing of the webserver vhost files is not recommended as those files get rebuilt from the template on each change.
Try checking the instructions here for the custom template build.
http://wiki.centos-webpanel.com/webservers-vhost-templates

APACHE + PHP-FPM
Configuration files are all user existing php-fpm configuration files, to get the list of files you can use this

ls -la /opt/alt/php-fpm*/usr/etc/php-fpm.d/users/USERNAME.conf

Add at the bottom

php_admin_value[open_basedir] = /home/USERNAME:/tmp

** Note that editing any of those files requires to restart php-fpm version you edited.

** Note that manual editing of the webserver vhost files is not recommended as those files get rebuilt from the template on each change.
Try checking the instructions here for the custom template build.
http://wiki.centos-webpanel.com/webservers-vhost-templates
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Orlox

So the "correct" way to do this is to:
From cwp admin panel
webserver settings -> WebServers Template Editor -> Php-fpm
Pick a file and click clone (I picked processes-50.tpl)
name it processes-51.tpl

add to the end
php_admin_value[open_basedir] = /home/%username%:/tmp

Then go to
webserver settings -> WebServers Main conf
go to the bottom
PHP-FPM Service Configuration
Choose from PHP-FPM default template: the template you just created, ffor example processes-51.tpl

check the Rebuild all vhosts on save

click save