This is an alternative to custom php.ini files.
Requirement: SSH Access
Time Needed: 5-10 minutes
As you noticed this is placed in the company owners section, so I will be talking about the methods the adminstrators can use, and not simple users.
In this article I am assuming you are runninng PHP as an Apache module, as if its a cgi module it will be systematic to use a php.ini file.
It can be really a headache when a certain user or even you need a certain option to be enabled while it represents a security risk; like shell_exec() or allow_url_fopen.
So, to enable this for a single account most of you will think of two things:
- Using a custom php.ini
- Using the .htaccess override.
Actually, in most of the cases if the server is really secured those methods wont work (I will discuss exactly those methods in details in another article, but this one is for the direct method that will work if you have SSH access).
So lets get started:
2. Backup your httpd.conf file.
3. Open your httpd.conf file.
4. Go to the accounts virtualhost, it should look like this:
# Other directives here
in this example i am assuming you use php5, if not you will see your proper version, or even see them all.
5. Now, we will write the option we want before the tag, but make sure you are in the module of the php version you use, for example if your server has php4 installed you should be playing in the
6. There are two kinds of directives you can set, boolean or value type, here is a list of all that can be changed:
To change a boolean one, add the following before the tag:
php_admin_flag name value(on|off)
To change a value one, add this:
php_admin_value name value
Note: you can use php_flag & php_value but i prefer the admin ones as they are unchangable.
7. Save your config file and restart apache.
8. Test everything to make sure its working correctly.
If you are not using cPanel ignore the next step. (I am not familier with other control panels and I dont know whether a similar step is needed)
9. When you are 100% sure that everything is working, run the following command to stablize your new configuration to remain if you update. In case you dont do this, after your first update all your custom edits will be removed.
10. Done! 😉 Visit us back 😀