Reputation: 13005
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 :
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.
Upvotes: 0
Views: 996
Reputation: 167
I've been using Apache, PHP, Xdebug, MySql since 2010 on Win Pros and it has been one of the most robust ecosystems on Windows I've encoutered. If the production goal is on Linux it is easy to run on Linux vm but it can be still be developed in Windows by sharing the vm directory. I use PhpStorm which adds to robust and script free experience. My server is very lean directly from Apache, PHP, XDebug binaries. MySql is separate install. Today I found how Apache changes its directory in windows. I wanted to get relative paths working in php.ini. Apache binaries zip can be found from apachelounge.com. windows.php.net offers php-binaries. Extract PHP 8.41 to some directory say c:\versions\ver841\php841. Apache gets extracted to its sibling directory c:\versions\ver841\httpd. It creates one lonely directory c:\versions\ver841\httpd\Apache24 and under it is the whole thing and bunch of directories. The directory c:\versions\ver841\httpd\Apache24\bin has special meaning. Apache starts at directory c:\versions\ver841\httpd\Apache24 but then changes to c:\versions\ver841\httpd\Apache24\bin. At that point it loads php.ini and relative addresses in php.ini are counted from Apache24/bin. PHP Extension directory would be three levels up and then happens dive to sibiling directory. In php.ini the loader would understand line - starting from apache bin:
extension_dir = ./../../../php_841/ext
This happens on my pc and I checked that double backslashes work too:
extension_dir = .\\..\\..\\..\\php_841\ext
Upvotes: 0
Reputation: 306
"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:\php\ini"
Upvotes: 0
Reputation: 105
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 be c:/php
, c:/Apache24
(for Apache 2.4) and c:/mysql
. So it doesn't matter.
Upvotes: -2