I’m using a laptop that runs on Windows 10 Home Single Language 64-bit Operating System
I’ve installed the latest version of XAMPP pre-configured installer on this laptop.
This has installed PHP 7.2.12 and Apache/2.4.37 (Win32) on my laptop.
I come across below note from the PHP Manual :
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.
This note has created couple of doubts in my mind which are as below :
- Does the root filesystem exist in Windows, especially in Windows 10 which I’m currently using on my laptop? If it does exist then which directory in Windows act as the root directory?
- If it does not exist then to which directory the Apache web server changes at startup in order to make PHP attempt to read php.ini?
I hope someone would clear my above doubts with some good explanation which would be in simple, lucid language and which should be easy to understand for me.
Thank You.
2
Answers
The root folder for the system is C:/Windows. But it has nothing to do with reading php.ini, because generally all configuration files (php, apache and mysql) are properly read every time. Mostly, I install xampp directly in c:/. The path of xampp will be
c:/xampp
and everything works fine.I also installed apache, php and mysql manually and separately without using wamp or xampp. And these will be placed directly under
c:/
, so that the paths would bec:/php
,c:/Apache24
(for Apache 2.4) andc:/mysql
. So it doesn’t matter.“Root” on *nix systems refers to the top-level folder. It looks like this: /
So the answer to your first question is: Yes, the root folder just means the top-level folder where the OS is installed, which on a default Windows set-up is the C: folder.
The answer to your second question is more tricky, since I’m not sure how Apache behaves on Windows. The note on the PHP manual page that has you concerned is only referring to *nix environments. This is a long-standing issue with PHP and Apache, in that they were both “born” out of *nix, and that is where they are most at home. They have been ported to Windows, but as an afterthought. I would highly recommend that you acquire a *nix development environment as soon as possible if you are going to be doing a lot of PHP development, because you will keep running into these kind of issues where the documentation is not intended for Windows users.
I believe that Apache on Windows will, by default, look for the php.ini file in the ServerRoot folder, which is set in httpd.conf. (Someone correct me if I’m wrong!) But if you want to place your php.ini file in a custom location, you can add a line like this to httpd.conf:
PHPIniDir “C:phpini”