Php ini где лежит windows

The configuration file (php.ini)
is read when PHP starts up. For the server module versions of PHP,
this happens only once when the web server is started. For the
CGI and CLI versions, it happens on
every invocation.

php.ini is searched for in these locations (in order):


  • SAPI module specific location (PHPIniDir directive
    in Apache 2, -c command line option in CGI and CLI)

  • The PHPRC environment variable.

  • The location of the php.ini file
    can be set for different versions of PHP. The root of the registry keys depends on 32- or 64-bitness of the installed OS and PHP.
    For 32-bit PHP on a 32-bit OS or a 64-bit PHP on a 64-bit OS use [(HKEY_LOCAL_MACHINE\SOFTWARE\PHP] for 32-bit version of PHP on a 64-bit OS use [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP]] instead.
    For same bitness installation the following registry keys
    are examined in order:
    [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z],
    [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and
    [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where
    x, y and z mean the PHP major, minor and release versions.
    For 32 bit versions of PHP on a 64 bit OS the following registry keys are examined in order:
    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x.y.z],
    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x.y] and
    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x], where
    x, y and z mean the PHP major, minor and release versions.
    If there is a
    value for IniFilePath in any of these keys, the first
    one found will be used as the location of the php.ini
    (Windows only).

  • [HKEY_LOCAL_MACHINE\SOFTWARE\PHP] or
    [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP], value of
    IniFilePath (Windows only).

  • Current working directory (except CLI).

  • The web server’s directory (for SAPI modules), or directory of PHP
    (otherwise in Windows).

  • Windows directory (C:\windows
    or C:\winnt) (for Windows), or
    --with-config-file-path compile time option.

If php-SAPI.ini exists (where SAPI is the SAPI in use,
so, for example, php-cli.ini or
php-apache.ini), it is used instead of php.ini.
The SAPI name can be determined with php_sapi_name().

Note:

The Apache web server changes the directory to root at startup, causing
PHP to attempt to read php.ini from the root filesystem if it exists.

Using environment variables can be used in php.ini as shown below.

Example #1 php.ini Environment Variables

; PHP_MEMORY_LIMIT is taken from environment
memory_limit = ${PHP_MEMORY_LIMIT}

The php.ini directives handled by extensions are documented
on the respective pages of the extensions themselves. A list of
the core directives is available in the appendix. Not all
PHP directives are necessarily documented in this manual: for a complete list
of directives available in your PHP version, please read your well commented
php.ini file. Alternatively, you may find
» the latest php.ini from Git
helpful too.

Example #2 php.ini example

; any text on a line after an unquoted semicolon (;) is ignored
[php] ; section markers (text within square brackets) are also ignored
; Boolean values can be set to either:
;    true, on, yes
; or false, off, no, none
register_globals = off
track_errors = yes

; you can enclose strings in double-quotes
include_path = ".:/usr/local/lib/php"

; backslashes are treated the same as any other character
include_path = ".;c:\php\lib"

It is possible to refer to existing .ini variables from
within .ini files. Example: open_basedir = ${open_basedir}
":/new/dir"
.

Scan directories

It is possible to configure PHP to scan for .ini files in a directory
after reading php.ini. This can be done at compile time by setting the
—with-config-file-scan-dir option.
The scan directory can then be overridden at run time
by setting the PHP_INI_SCAN_DIR environment variable.

It is possible to scan multiple directories by separating them with the
platform-specific path separator (; on Windows, NetWare
and RISC OS; : on all other platforms; the value PHP is
using is available as the PATH_SEPARATOR constant).
If a blank directory is given in PHP_INI_SCAN_DIR, PHP
will also scan the directory given at compile time via
—with-config-file-scan-dir.

Within each directory, PHP will scan all files ending in
.ini in alphabetical order. A list of the files that
were loaded, and in what order, is available by calling
php_ini_scanned_files(), or by running PHP with the
—ini option.

Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d,
and that the path separator is :...

$ php
  PHP will load all files in /etc/php.d/*.ini as configuration files.

$ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php
  PHP will load all files in /usr/local/etc/php.d/*.ini as
  configuration files.

$ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php
  PHP will load all files in /etc/php.d/*.ini, then
  /usr/local/etc/php.d/*.ini as configuration files.

$ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php
  PHP will load all files in /usr/local/etc/php.d/*.ini, then
  /etc/php.d/*.ini as configuration files.

weili

2 years ago

For someone who's also wondering.

PHP can work even if there is no configuration file(php.ini) loaded,
it will simply applies the default values to directives.

ohcc at 163 dot com

7 years ago

in php.ini you can reference to an existing directive or an environment variable using the syntax ${varname}.

Here are some examples.

sys_temp_dir = "${WINDIR}"

--- ${WINDIR} will be replaced by $_ENV['WINDIR'] at runtime

--- you can set environment variables by Apache and use them in php.ini
--- FcgidInitialEnv AUTHOR "WUXIANCHENG"
--- error_log = "${AUTHOR}.log"

error_log = "${sys_temp_dir}"

--- ${sys_temp_dir} will be replace by the value of sys_temp_dir

Also you can use PHP constants in php.ini, but DONT'T wrap them in ${} or "".

error_log = "/data/"PHP_VERSION"/"

--- it works like this php code:

$error_log = "/data/" . PHP_VERSION . "/";

Asked

Viewed
75k times

I ran phpinfo and it said it was in C:\Windows but it’s not there. It’s not in the php folder. I did a system search and it wasn’t found.

Where is it hiding?

  • windows
  • php

asked Dec 21, 2012 at 4:52

Ryan Peschel's user avatar

Ryan PeschelRyan Peschel

11.2k19 gold badges75 silver badges136 bronze badges

7

  • how you installed php … wamp ,xamp or other ?

    Dec 21, 2012 at 4:54

  • in wamp its in wamp\bin\php\php5.3.9 in xamp \xampp\php\php.ini

    Dec 21, 2012 at 4:54

  • On my PC it is located C:\Program Files\PHP. If it is not there why not use explorer to search for it (and then make a note for future reference)

    Dec 21, 2012 at 4:56

  • you can check this by <?php phpinfo();

    Dec 21, 2012 at 4:56

  • It may be hidden for some reason. Try turning on «Show hidden files and folders» in Windows Explorer.

    Dec 21, 2012 at 5:00

1 Answer

Run this code (and I am assuming your php is running, you are not able to just locate the php.ini file)

<?php

phpinfo();

?>

And check the location of the config file:

Location

Bert H's user avatar

Bert H

1,0971 gold badge15 silver badges29 bronze badges

answered Dec 21, 2012 at 4:56

swapnesh's user avatar

swapneshswapnesh

26.4k22 gold badges94 silver badges126 bronze badges

6

  • This answer is lacking hand drawn objects.

    Dec 21, 2012 at 5:00

  • @TimPost yes check the screenshot ..he is referring to the above one while php.ini location is in the circled one..let me know if im missing something :)

    Dec 21, 2012 at 5:00

  • The Loaded Configuration file says None.

    Dec 21, 2012 at 5:02

  • @RyanPeschel Did you try putting one in the config file path and see if it loads? You may just have a somewhat botched installation on your hands.

    Dec 21, 2012 at 5:03

  • For anyone else seeing «none» there: In the default windows download, the ini files have -production or -development AFTER the .ini in the filename, which means they are not picked up.

    Dec 13, 2021 at 0:57

  • The Overflow Blog
  • Featured on Meta

Linked

Related

Hot Network Questions

  • Why does causality imply that the system function is analytic?

  • Idiom for unexpected solution?

  • How to take good photos of stars out of a cockpit window using the Samsung 21 ultra?

  • 以后我少的一点儿 what does this mean?

  • How can I prove an airline ticket is fake?

  • mv a bunch of files, but ask for each file

  • For which subgroups the transfer map kills a given element of a group?

  • Why is the central truss segment of the ISS called S0?

  • Schengen to Schengen with connecting flight via UK (non-Schengen)

  • Approximation of factorial numbers using partial Stirling’s approximation

  • Did Netanyahu recently say «We will turn Gaza into a deserted island»?

  • Meaning of «schon einmal»

  • Nobility manga where female main character is forced to cross-dress by her family but encounters demigods

  • Is there a reasonable explanation for why my professor submitted my recommendation letter months early?

  • Why is a stray semicolon no longer detected by `-pedantic` modern compilers?

  • Contradiction in negative mass interactions according to GR

  • Beacon contract contructor seems to call address 0x02?

  • If there is still space available in the overhead bin after boarding and my ticket has an under-seat carry-on only, can I put my bag up there?

  • Closest in meaning to «It isn’t necessary for you to complete this by Tuesday.» — is the question’s answer wrong?

  • Can I switch between my two passports from the same country?

  • Can a social sciences doctoral thesis be just 65k words long?

  • What could happen if my university loses its R2 status?

  • Spacing on text macros

  • Eliminating one variable from two simple polynomial equations

more hot questions

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

The php.ini file is a configuration file used by PHP to specify settings for your web server, such as file upload size, error reporting, and memory usage. However, the location of the php.ini file can vary depending on your server setup and operating system.

In this tutorial, we will explore a few methods to help you locate the correct php.ini file on your web server.

Method 1: Use phpinfo() function

The phpinfo() function displays detailed information about your PHP configuration, including the location of your php.ini file. To use this function, follow these steps:

  1. Create a new PHP file on your web server. You can name it anything you like, but for this tutorial, we will name it phpinfo.php.
  2. Open the phpinfo.php file in a text editor and add the following code:
  3. Save the file and upload it to your web server using FTP or your web hosting control panel.
  4. Open your web browser and navigate to the URL of the phpinfo.php file, for example http://example.com/phpinfo.php. Replace “example.com” with your own domain name.

You should see a page with detailed information about your PHP configuration. Look for the “Loaded Configuration File” section, which should contain the full path to your php.ini file.

Locate php.ini with phpinfo()

Locate php.ini with phpinfo()

Method 2: Use the command line

If you have access to the command line, you can use the `php --ini` command to find the location of the php.ini file. Follow these steps:

  1. Log in to your web server using SSH or another terminal application.
  2. Type the following command and press Enter:
    php --ini | grep php.ini
    
  3. This command will display a list of all the php.ini files that are currently being used, as well as their locations.

Locate php.ini for CLI

Locate php.ini for CLI

Method 3: Check default locations

Depending on your operating system and server configuration, the php.ini file may be located in one of the default locations. Here are some common default locations:

On Linux:

  • /etc/php.ini
  • /etc/phpX/apache2/php.ini (where X is the PHP version)

On Windows:

  • C:\Windows\php.ini
  • C:\php\php.ini

You can try searching for the php.ini file in these locations using your FTP or file manager.

If none of these methods work, you can contact your web hosting provider or system administrator for assistance in locating the php.ini file on your server.

Conclusion

The php.ini file is an essential configuration file for PHP. By following the methods outlined in this tutorial, you should be able to locate the correct php.ini file on your web server. Remember, the location of the php.ini file can vary depending on your server setup and operating system, so it’s important to double-check the location before making any changes to the file.

In this tutorial, we’re going to discuss php.ini—the main configuration file in PHP. From the beginner’s perspective, we’ll discuss what it’s meant for, where to locate it, and a couple of important configuration settings it provides.

What Is php.ini?

Whether you’re a PHP beginner or a seasoned developer, I’m sure that you’ve heard of php.ini: the most important PHP configuration file. 

When PHP is run, it looks for the php.ini file in some specific locations and loads it. This file allows you to configure a few important settings that you should be aware of. Quite often, you’ll find you need to tweak settings in the php.ini file.

On the other hand, it’s certainly possible that you’ve never needed to modify php.ini. PHP can run happily with the settings provided in the default php.ini file, since PHP ships with these default recommended settings. In fact, there are no critical configuration parameters that you must set in order to run PHP. 

However, the php.ini file provides a couple of important settings that you want to make yourself familiar with. In fact, as a PHP developer, it’s inevitable, and you’ll encounter it sooner rather than later.

Where Is php.ini?

In this section, we’ll see how to find the php.ini file which is loaded when you run the PHP script. This can be tricky—the location of the php.ini file vastly varies by the environment you’re running PHP with. If you’re running Windows, you’ll likely find the php.ini file within the directory of your PHP installation in the system drive. On the other hand, if you’re running another operating system, then it’s difficult to guess the exact location of the php.ini file—there are several possibilities.

This is where the phpinfo() function comes to the rescue. It will tell you where php.ini is located, and it will also output all the important PHP configuration information. 

You can run phpinfo() by creating a .php file and calling that function. Go ahead and create the phpinfo.php file with the following contents and place it in your document root:

1
<?php
2
phpinfo();
3
?>

Load this file in your browser, and you should see the output of phpinfo(). Look for the following section.

LocationLocationLocation

As you can see, there are two sections. The first one, Configuration File (php.ini) Path, indicates the default path of the php.ini file in your system. And the second one, Loaded Configuration File, is the path from where the php.ini file is being loaded when PHP is run.

So you can edit the php.ini file indicated in the Loaded Configuration File section, and that should work in most cases. Of course, if you’re running PHP as an Apache module, you need to restart the Apache server to make sure that the changes you’ve made in the php.ini file are reflected.

On the other hand, if you’re using software like WAMP or XAMPP to run your web development stack, it’s even easier to modify the php.ini file—you can directly access it via the WAMP or XAMPP UI.

In the next section, we’ll explore a couple of important settings in the php.ini file.

Important Settings in php.ini

The php.ini file provides a lot of configuration directives that allow you to modify various behaviors of PHP. In fact, when you open the php.ini file, you may get overwhelmed by the number of directives it provides. I’ll try to group them based on their behavior, and I hope it’ll be easy for you to understand.

Of course, we won’t go through each and every directive, but I’ll try to cover the most important ones. Let’s have a look at the types of directives that we’re going to discuss.

  • error handling directives
  • file upload directives
  • security related directives
  • session directives
  • miscellaneous directives

Error Handling Directives

In this section, we’ll go through directives that are related to error handling and are useful for debugging during development.

display_errors

The display_errors directive allows you to control whether errors are displayed on the screen during script execution. You can set it to On if you want errors to be displayed on the screen and Off if you want to disable it. It’s important that you don’t ever enable this on a production site—it will slow your site down and could give hackers valuable clues to your site’s security vulnerabilities.

error_reporting

This directive allows you to set the error reporting level. Mostly, this directive works in conjunction with the display_errors directive. This directive can accept E_ALL, E_NOTICE, E_STRICT, and E_DEPRECATED constants.

You can set it to E_ALL if you want to display all types of errors like fatal errors, warnings, deprecated functions, etc. You can also combine the different values if you want to filter out specific errors. For example, if you want to display all errors except notices, you can set it to E_ALL & ~E_NOTICE.

error_log

On a production website, you need to make sure that PHP doesn’t display any errors to the client browser. Instead, you can log errors somewhere so that later on you can refer to them if something goes wrong with your site. The error_log directive allows you to set the name of the file where errors will be logged. You need to make sure that this file is writable by the web server user.

File Upload Directives

In this section, we’ll see a couple of important directives that allow you to enable file uploading capabilities in your PHP forms.

file_uploads

This is a boolean directive which allows you to enable HTTP file uploads. If you set it to On, you can use the file field in your forms and users will be able to upload files from their computer. On the other hand, if you set it to Off, file uploading is disabled altogether.

upload_max_filesize

If you have enabled the file upload feature on your website and you’re facing difficulties in uploading files, this is the directive you should check first. It allows you to set the maximum size of a file that can be uploaded.

By default, it’s set to 2MB, and thus users can’t upload files larger than 2MB. You can fine-tune this value as per your requirements—often you’ll want to increase this limit to allow larger file uploads.

post_max_size

This setting allows you to set the maximum size of the POST data in your forms. When a user submits a form with the POST method, the total POST data size should not exceed the value you’ve set in this directive.

This should be larger than the value you’ve set in the upload_max_filesize directive, since file uploads are handled with POST requests.

Security Directives

In this section, we’ll see a few important directives that are related to security.

allow_url_fopen

The allow_url_fopen directive is disabled by default. But when it’s enabled, it allows remote file inclusion in PHP file functions. This means that your PHP files can include code from other servers. Be wary about enabling this—if your code is subject to an injection attack, remote file inclusion will make it much easier for a malicious user to hijack your server.

allow_url_include

The allow_url_include directive is similar to the allow_url_fopen directive, but it enables remote file inclusion in include functions. It allows you to include remote files in the include, include_once, require, and require_once functions.

If you want to enable this directive, you need to make sure that you’ve enabled the allow_url_fopen directive as well.

Session Directives

Session management is one of the most important aspects when you’re working with PHP. In this section, we’ll go through a couple of important session directives.

session.name

The session.name directive allows you to set the name of the session cookie. By default, it is set to PHPSESSID, but you can change it to something else by using this directive.

session.auto_start

If you set the value of the session.auto_start directive to 1, the session module in PHP starts a session automatically on every request, and thus you don’t have to use the session_start function in your scripts.

session.cookie_lifetime

The session.cookie_lifetime directive allows you to set the lifetime of a session cookie. By default, it is set to 0 seconds, and it means that the session cookie is deleted when the browser is closed. This is a really useful setting which allows you to set up a «remember me» kind of functionality, allowing your users to pick up where they left off on your site.

Miscellaneous Directives

In this last section, we’ll see a couple of other directives that are important in the context of PHP script execution.

memory_limit

The memory_limit directive allows you to limit the maximum amount of memory a script is allowed to use.

You want to fine-tune this directive as per your requirements, and you should not set this too high to avoid memory outages on your server—poorly written or buggy scripts can eat up all the memory on your server if you let them!

max_execution_time

The max_execution_time directive sets the maximum amount of time a script is allowed to run before it is terminated. The default is 30 seconds, and you can increase it to a reasonable limit as per your requirements if you need to.

Similar to the memory_limit directive, you should not set this too high to avoid issues on your server.

max_input_time

The max_input_time directive allows you to set the maximum amount of time a script is allowed to parse incoming form data from a GET or POST.

If you have forms on your website that submit a large amount of data, you might like to increase the value of this directive.

Conclusion

It’s impossible to cover each and every directive within a single article, but I’ve tried to cover the important ones. Feel free to post your queries if you want to know about any specific directives, and I’ll be happy to help!

As a PHP developer, it’s important that you understand the different directives in the php.ini file, and that should help you to fine-tune your PHP configuration to your requirements.

The Best PHP Scripts on CodeCanyon

Explore thousands of the best and most useful PHP scripts ever created on CodeCanyon. With a low-cost one-time payment, you can purchase these high-quality WordPress themes and improve your website experience for you and your visitors.

Here are a few of the best-selling and up-and-coming PHP scripts available on CodeCanyon for 2020.

Did you find this post useful?

Sajal Soni

Software Engineer, FSPL, India

I’m a software engineer by profession, and I’ve done my engineering in computer science. It’s been around 14 years I’ve been working in the field of website development and open-source technologies.

Primarily, I work on PHP and MySQL-based projects and frameworks. Among them, I’ve worked on web frameworks like CodeIgnitor, Symfony, and Laravel. Apart from that, I’ve also had the chance to work on different CMS systems like Joomla, Drupal, and WordPress, and e-commerce systems like Magento, OpenCart, WooCommerce, and Drupal Commerce.

I also like to attend community tech conferences, and as a part of that, I attended the 2016 Joomla World Conference held in Bangalore (India) and 2018 DrupalCon which was held in Mumbai (India). Apart from this, I like to travel, explore new places, and listen to music!

PHP php.ini Configuration File location

Last updated on | 2 replies

In this article, we will guide you on a treasure hunt to find the php.ini configuration file, unravel its mysteries, and unlock the full capabilities of your PHP environment. Whether you are a seasoned PHP developer or a newcomer to the world of web development, understanding the ins and outs of this essential configuration file will make your journey smoother and your projects more efficient. So, let’s embark on this exciting quest to locate and master the php.ini file!

Method 1

One way to find out exactly which php.ini file your web sever is using is by creating a new PHP file in document root called info.php.

info.php

<?php
phpinfo();
?>

Load this file in your browser, press CTRL + F (or Command + F on Mac) and search for “Loaded Configuration File”. You should see something like

/etc/php/8.1/apache2/php.ini

This will tell you the exact location of the php.ini file you want to edit.

Method 2

In Linux, run this command to locate the PHP.ini configuration file.

php -i | grep "Loaded Configuration File"

Or in Windows Command Line:

php -i | findstr /c:"Loaded Configuration File"

The result should be something like this:

Loaded Configuration File => /etc/php/8.1/cli/php.ini

In the above example, we can see that the PHP install is located in /etc/php/8.1. Note that there are three different configuration files you should we aware of:

CLI

/etc/php/8.1/cli/php.ini is for the CLI PHP program. Changes to this config file will only affect PHP as it runs in the terminal – it will NOT affect the web server.

Apache

/etc/php/8.1/apache2/php.ini is for the PHP plugin used by Apache. This is the one you need to edit if you are using the Apache web server.

Nginx or Apache with PHP-FPM

/etc/php/8.1/fpm/php.ini is a fastcgi-compatible ‘wrapper’ for PHP processing. This is the one you need to edit if you’re using the Nginx web server or Apache with PHP-FPM.

Method 3

Using the locate command in Linux,. If it’s not already installed, run  sudo apt update && sudo apt install mlocate.

You should see a list of php.ini files here. Try editing one of them and restarting you web server to see if makes the required changes.

Editing php.ini in Linux

Apache

On Apache, php.ini is usually located in /etc/php/8.1/apache2/php.ini. Replace 8.1 with your own version, e.g, php5.6php7.4, etc.

To edit:

sudo nano /etc/php/8.1/apache2/php.ini

However, if you are using PHP FPM, it may be located in /etc/php/8.1/fpm/php.ini. Replace 8.1 with your own version, e.g, php5.6php7.4, etc.

To edit:

sudo nano /etc/php/8.1/fpm/php.ini

To save file and exit, press CTRL + X, press Y and then press ENTER

You must restart Apache after altering php.ini.

sudo systemctl restart apache2

If you are using PHP-FPM, you must restart that service. Replace php8.1 with your own version, e.g, php5.6php7.4, etc.

sudo service php8.1-fpm restart

Nginx or Apache with PHP-FPM

Nginx uses PHP FPM and php.ini is usually located in /etc/php/8.1/fpm/php.ini. Replace 8.1 with your own version, e.g, php5.6php7.4, etc.

sudo nano /etc/php/8.1/fpm/php.ini

Save and exit (press CTRL + X, press Y and then press ENTER)

You must restart Nginx after altering php.ini.

sudo systemctl reload nginx

Older Versions

For versions of Ubuntu lower than 16.04, /etc/php/5.6/,/etc/php/7.0/,/etc/php/7.1/, and so on, are replaced by /etc/php5/ and so on. Otherwise, these paths remain accurate.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

  • Php for windows 10 download
  • Php default charset windows 1251
  • Php convert utf 8 to windows 1251
  • Photoshop скачать windows 10 besplatno
  • Php apache web server windows