'Overwrite' php.ini settings - directory

I have a folder, and for all php files in that folder (or even better, in that folder or any folders within it) I'd like to make some changes to the php settings. Can I just place a php.ini file in that folder with those settings I'd like to change?
If so, any reason why this wouldn't be working for me? It's my own server.
Thanks!
edit: I'd like to be able to use a local php.ini file, as I've been able to do with several webhosts. Is this a possibility?

It looks like you're wanting to use per-directory php.ini files which are available as of PHP 5.3. If it's your own server, I'd like to think you're happy to keep up with the latest stable releases (currently 5.3.2). Back to ini files, to quote that manual page:
Since PHP 5.3.0, PHP includes support for .htaccess-style INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.
In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). Only INI settings with the modes PHP_INI_PERDIR and PHP_INI_USER will be recognized in .user.ini-style INI files.

You'll have to use a .htaccess file for that. There a section in the PHP manual about that:
http://php.net/manual/en/configuration.changes.php
For more general information on htaccess files you can read:
http://en.wikipedia.org/wiki/Htaccess
or
http://httpd.apache.org/docs/2.0/howto/htaccess.html

The .htaccess files are typically the best way to go for an Apache server. However, to answer your original question, yes you can set a php.ini file in every directory if you want. However, in order for it to work, PHP must be set to run as PHP-CGI. My guess is that you are running PHP as an Apache module.
See this link for reference on where PHP looks for php.ini and when it looks for it: http://www.php.net/manual/en/configuration.file.php

You could also use ini_set(), if you wanted to do it in code.

instead of modifying php.ini file for each folder you would be required to modify a .htaccess file. Keep the file in the folders with whatever setting you like. You cant do this with a php.ini file since changes in php.ini are considered server wide

Related

I have a Windows hosting and I need to use Wordpress on it

I know that this hosting is not the best for Wordpress but unfortunately I can't change it anymore, whenever I try to install a plugin it shows the error "No working transports found" I researched how to fix it and everywhere it shows me to uncomment a php line. ini but I need to fix this on Windows, can anyone help me?
Yes, you will need to uncomment a line in php.ini
You need to:
(1) find the location of php.ini in your Windows server,
(2) open the php.ini file, search for ;extension=openssl and uncomment that line by removing the ;
Note: If you're running a PHP version older than 7.2.0, the extension's file name may be extension=php_openssl.dll instead of ;extension=openssl in the php.ini file.
(3) if you’re running PHP as an Apache module, restart the Apache server to make sure the changes are reflected.
How to Find the Location of php.ini in Your Windows Server:
To find the location of php.ini in your Windows installation, you will need to run the phpinfo() function.
Follow the steps below:
(1) Create an empty file called phpinfo.php and place it in your document root,
(2) Edit the file and place the following content in it:
<?php
phpinfo();
?>
(3) Save and close the file.
(4) Open the file in your browser and you will see the output of phpinfo().
(5) Search for Loaded Configuration File and you will find the location of your php.ini file.
Once you have found the php.ini file, you may then proceed to open it and uncomment ;extension=openssl.

nginx default configuration files

What does it mean when I see both "nginx.conf" and "nginx.conf.default" configuration files? I also see "fastcgi.conf" and "fastcgi.conf.default" and "fastcgi.params" and "fastcgi.params.default" etc, in the same folder.
Does ".conf.default" get applied and then the ".conf" gets applied on top of it?
Nginx will strictly load the configuration from the .conf files unless you haven't specified otherwise (like using an include rule and include a file with other extension that .conf).
.conf.default files are not applied on top of the .conf files. In fact they are not applied at all.
As far as I know this behaviour appears on debian when you do update nginx (but I might be wrong).

Migrating Drupal

Currently I have a single drupal site installed on apache 2.2 with php 5.3 on RHEL 6. I am moving servers and am trying to migrate the site. I have imported the database and htaccess, but I cannot access any of the pages other than the root of the site.
You may need to disable clean URLs before exporting the database, try to add ?q= before each path.
That happens when:
a) Apache mod_rewrite is not enabled. If you have root access then do sudo a2enmod rewrite
or
b) .htaccess file at the root folder isn't there, so you need to copy it again.
Here's a troubleshoot check list for mod_rewrite issues:
Make sure Apache's rewrite module is enabled: sudo a2enmod rewrite.
Make sure original .htaccess file is there in the root of your Drupal installation.
Make sure that the existing .htaccess file is getting read by Apache. To test it, add a this line in the beginning of the file and you should get a 500 Internal Server Error: ThisIsReallyABadSyntax.
If the .htaccess file is not in effect, make sure that the AllowOverride directive in the main Apache config file (usually /etc/apache2/httpd.conf on debian-based distros) is set to All. It might be set to None by default.
Finally, make sure that the clean URLs feature is enabled in Drupal settings.
With the phpinfo(); compare all the server specs, just to be sure both server are quite the same or similar.
Steps to migrate Drupal correctly:
Go to Configuration
find Clean URLs
Disable tick inside!
Clean cache!
Download your site file
Download your database
Create new database in your new site
Transfer file and database
Log in
10.Do this step to enable Clean URLs:
It's work 100% guaranteed !
Steps:
1. Download - Dev version (7.x-dev)
2. Find file .htaccess
3. just copy it to your server
4. That's it !

Wordpress Configuration File

I have insatlled wordpress 3.3.1 recently. I have not confirgured wp-config.php file before installation, after installation, i have copied the wp-config-sample.php to wp-config.php & edit the details accordingly, but this wp-config file is not reflecting actually.
What may be the reason, how to make this enable so that wp-config file will be included while loading wordpress files,
Moreover from where the db & other settings are loaded in Wordpress.
Thanks !
Make sure that wp-config.php is in the right location (webroot), and that the file has the appropriate permissions. If everything checks out ok, check the apache logs.
Please make sure that you follow the following steps
I can only assume you are on a windows machine, since I've had the same problem, but not in Linux.

Wordpress Blank Install Page

I uploaded a freshly downloaded copy of Wordpress 4.2.2 here: http://www.onedayonemillion.com/test/ and all I get is a blank page.
There are no .htaccess or wp-config.php files in the root directory.
No database has been connected yet.
I tried the same in another directory (/dev/) and it did the same.
I have no plugins installed or activated.
This is a fresh copy.
I added an phpinfo file here: http://www.onedayonemillion.com/test/info.php
Why can't I even get the install page to show up?
I didn't understand why there is no wp-config.php in the directory, it would be good you post what is in the directory. Anyway, you can check items like (sometimes it is just that):
some files with no ending "?>" ending the file;
any require_once methods calling non-existing files
(you said no, but) wp-config has wrong or non-set definitions (user, database)
check permissions/ownership to the folder
Well, I know it can be lame, but I had problem with definition in WPLANG define,
so I put an
echo "<br> there is no error until here";
through the files untill I find that was missing a comma at the definition. If the phrase is displayed, your installation files untill that point are working out.
Your phpinfo says the display_errors is off.
modify your php.ini with this line:
display_errors = on
you should restart the server after modification.
you can only track the error only if the error reporting is on in the server

Resources