Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP php.ini file in the web public root directory ? is it safe enough

Tags:

php

I heard when you want to change the php.ini settings when you don't have access to the php.ini in the root level that you can upload a php.ini to the web-root, is this correct ?

Another way to customize your PHP settings is to create a file named php.ini and to upload it to your web server. This works in a way similar to the .htaccess file except you don’t have to add “php_value” at the beginning of the line

if this correct that means anyone who type

www.xx.com/php.ini 

should see the settings ? isnt this a security risk ?

like image 322
mahen3d Avatar asked Sep 06 '12 07:09

mahen3d


People also ask

Do I need a PHP ini file?

It is where you declare changes to your PHP settings. The server is already configured with standard settings for PHP, which your site will use by default. Unless you need to change one or more settings, there is no need to create or modify a php. ini file.

What is PHP ini file why it is used?

The php. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits.

What is basic PHP INI?

The php. ini file is the standard configuration file in PHP-based applications. It is used to set upload sizes, display errors, resource limits, file timeouts, and many other things to manage the Apache server. You already have default PHP settings installed on your server. There's no need to create or edit a php.


2 Answers

It's safe from people editing it. However it is visible to anyone who stumbles across your php.ini, so it's better to use .htaccess to disallow people from seeing it so readily.

like image 44
Bashevis Avatar answered Oct 03 '22 14:10

Bashevis


I'd stick to using ini_set instead of putting a php.ini file up there.

But if you had to, you had better secure it with the right set of .htaccess rules. Something like

<Files php.ini>
Order allow,deny
Deny from all
</Files>

The above rule will prevent anyone accessing that file as www.xx.com/php.ini

like image 90
Anirudh Ramanathan Avatar answered Oct 03 '22 15:10

Anirudh Ramanathan