views:

41

answers:

3

I don't have any access to the php.ini and httpd.conf files. Are there any procedure to override (or add some) settings of php.ini and httpd.conf files from my php application?

A: 

You can use ini_set() for some settings or by modifying the setting via .htaccess http://www.php.net/manual/en/ini.list.php

The changeability of ini settings using these methods varies depending on the variable (see "Changeable" column). This page explains what each of those PHP_INI_* mean.

For settings in httpd.conf (eg: that pertain to Apache itself rather than PHP), you'll need to use .htaccess files. But of course your server's AllowOverride has to allow you to use them. Contact your hosting provider for information on this.

NullUserException
and for apache (httpd.conf)??
chanchal1987
@chanchai You can't. If you could, it would be a huge security issue, wouldn't it?
NullUserException
@NullUserException: .htaccess files (http://httpd.apache.org/docs/2.2/howto/htaccess.html) can be used.
Richard Fearn
@Richard Then technically you aren't using PHP. And you'll also need `AllowOverride` in httpd.conf to be set to a level that lets you change settings.
NullUserException
+1  A: 

For Apache configuration: this can (for certain settings) be done using .htaccess files:

.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

You may be unable to change certain settings using .htaccess files; the directives that you can use are specified in the main Apache configuration using AllowOverride directives.

For PHP settings: this can be done using the ini_set function:

Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.

This appendix shows you which settings can be changed from scripts.

Richard Fearn
+1 for the link to that appendix, never seen it before but was pleasantly surprised to learn that short tags can be turned on and off with `ini_set`... had always assumed that setting would be immutable.
no
@no: that specific option, like some other, can't be altered using `ini_set`. cuz php have to parse the page before executing your `ini_set` call, and if it had that option disabled it won't be able to parse your call that's inside `<? ?>`
aularon
A: 

For apache, use .htaccess, which will grant you control over much of what would httpd.conf would have given you.

For PHP look here: PHP: How to change configuration settings, one of the method is having settings put also in the .htaccess file (when certain php modules exist in the server).

aularon