Automatically run /scripts/ensure_vhost_includes --all-users after account creation

M373H

Member
Jan 18, 2015
16
0
1
cPanel Access Level
Root Administrator
Hello,

I'm wondering if there is a way to make cPanel run the following commands automatically every time account is created:
Code:
/scripts/ensure_vhost_includes --all-users
/etc/init.d/httpd restart

If that is not possible, can I set a cronjob for the above commands to run hourly under user root?

Thank you :)
 

cPanelPeter

Technical Analyst III
Staff member
Sep 23, 2013
575
21
143
cPanel Access Level
Root Administrator
Twitter
Hello,

Is there a particular reason on why you would want to (or need to) do that?

I suppose you could use a scripts hook to do this.

However, it's not really necessary.
 

M373H

Member
Jan 18, 2015
16
0
1
cPanel Access Level
Root Administrator
Hello,

Is there a particular reason on why you would want to (or need to) do that?

I suppose you could use a scripts hook to do this.

However, it's not really necessary.
Thank you for your reply,

I wanted to restrict all users to a global php.ini file and also have the ability to create custom php.ini files for specific users. I followed the method in this thread by cPanelTristan However in order to restrict new created accounts to the global php.ini file, I have to run the above mentioned commands. I don't to want to do that manually every time account is created.

Two Important Notes on Above Method

2. New accounts aren't restricted

Any accounts created after you have locked users into the global php.ini file using the <Location /></Location> tags around suPHP_ConfigPath in userdata location will not be restricted to it. Each time a new account is created, the following must be run after the account creation to lock that account to the global restriction:

Code:
/scripts/ensure_vhost_includes --all-users
/etc/init.d/httpd restart
That's why I'm looking for a way to automate the process.

If there is a better way to restrict users to a global php.ini while being able to set custom php.ini files to specific users, please let me know :) I'm currently using PHP 5.4

Thank you :)
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello,

I'm wondering if there is a way to make cPanel run the following commands automatically every time account is created:
Code:
/scripts/ensure_vhost_includes --all-users
/etc/init.d/httpd restart

If that is not possible, can I set a cronjob for the above commands to run hourly under user root?

Thank you :)
Hello,

You could use a post account creation script hook, as documented here:

Accounts::Create

Thank you.