Can a default locale value be placed in file php.ini or .htaccess?
The equivalent of the PHP function
setlocale(LC_MONETARY, 'it_IT');
for example.
It can. Take a look at intl.default_locale.
There's nothing in the php.ini file to help you. But as an alternative you could try setting environment variables from file .htaccess:
SetEnv LC_ALL it_IT.UTF-8
But these settings only take effect for the CGI and FastCGI versions of PHP at best, not for the usual mod_php installation.
Sadly there is no way at this time to set this configuration PHP-wide.
I've been looking at the code and the ENV method doesn't work since LC_* variables are not treated like the other ones.
You can patch PHP to use your locale instead of the default 'C' one or make a module if you really need to.
But the actual way to go is to do it at the script level.
Using auto_prepend_file in php.ini lets you run add some code before any script executed, so it looks like a nice place to use setlocale.
Related
I am a complete newb to Apache Servers. So far, I understand that Apache configuration is made in httpd.conf but there is one environment variable called SetEnv that has been bugging me. In one demo code I am looking at, there is
SetEnv APPLICATION_ENV "development"
and in another folder, I can see a "development" folder with other php files in it with database configurations. So, I am kind of not very clear as to the use of SetEnv. Does it point to files that will show DB configs?
SetEnv sets an internal environment variable in apache that you can use in apache modules or pass to CGI scripts.
Syntax is :- SetEnv variable value
So in SetEnv APPLICATION_ENV "development" you can use APPLICATION_ENV as a variable and apache will use it's value="development" instead.
I am running a script and i am getting the following error:
WARNING: is_readable() [function.is-readable]: open_basedir restriction in effect. File(/usr/share/php/Am/View/Helper/HeadScript.php) is not within the allowed path(s): (/home/1205915141/members-net/:/tmp:/usr/share/pear/) in line 198 of file /home/1205915141/members-net/public_html/library/Zend/Loader.php
I asked my host to remove the restriction but they said they wont because of security reasons. So resolved to do it my self by overriding the php.ini with an htaccess like this:
php_value open_basedir /usr/share/php/
but it wont work. Im not sure what is exactly the problem, whether the syntax or the path. Could you please give me a hand?
Thank you.
What PHP version do you use - maybe < PHP 5.3?
See http://php.net/manual/en/ini.core.php
For PHP < 5.3 this value was PHP_INI_SYSTEM, which means it can only be set from within php.ini or httpd.conf. Starting with PHP 5.3 its value is PHP_INI_ALL, so you can set it from within a htaccess file.
I set opcache.enable=0 in opcache.ini
Now I want to enable opcache from my htaccess file using
php_flag opcache.enable On
But it is not working
Is there any way, I disable opcache in opcache.ini, and enable in my application's htacces file.
Thanks
The simple reply here is that you can't enable. OPcache is a zend_extension and as such can only be enabled at a system level. However, there is a simple wrinkle here in the opcache.enable is a PHP_INI_ALL directive and can be set to 0 anywhere either at a directory or program context. So having opcache.enable=1 in the system configuration and then setting
php_flag opcache.enable Off
should work, and this will disable caching for the scope of that request
Also read up on the directive opcache.blacklist_filename (which is a bit of a misnomer, BTW). This allows you to define files and file hierarchies that are not to be cached (but once blacklisted you can't then create exceptions or unblacklist files at runtime.
Also since the enable is a PHP_INI_ALL directive, there is nothing stopping you adding a bit of code logic disable caching for the scope of that request in an auto_prepend_file included script instead of using an htaccess php_flag directive, but not that once disabled, you then can't re-enable it, so you can only use the blacklist to control caching at a file level.
I need to use time zone PST for my application, so i have set these settings in .htaccess file of my zend project. --
php_value date.timezone "America/Los_Angeles"
But it is not being reflected in my project, when i echo the date it is showing me Indian time. What am missing in this please help me to know.
Ensure .htaccess files is of any use. It may be that your httpd is not even reading it (most likely) or it does, but ignores your php_value (less possible as it usually ends with error 500)
So, I have a development server running OpenSuse with apache. There are loads of projects on this server, some of them have an online/live counterpart.
Each project has a separate subdomain.
How do I rewrite all requests for robots.txt to one "default"-file, server wide?
My goal is to prevent indexing from search-bots.
I believe there is no easier way than to set an Alias in every VirtualHost directive:
Alias /robots.txt /home/path/to/generic/robots.txt
I'm happy to stand corrected by a truly global solution, though.
I was having the same problem and found that I could place the Alias declaration that Pekka suggests in the httpd.conf outside of the VirutalHost directive and it applied to all sites.