PHP and IIS7--> I updated the Environment %PATH% but PHP's Path not updating, even after cycling IIS

StackOverflow https://stackoverflow.com/questions/23342524

  •  11-07-2023
  •  | 
  •  

Question

I've got a batch file rigged up to do Mysql backups on two different servers, both running IIS7, both with their "Path" environment variables now including the path to MySQL's bin subdirectory (path is the same on both systems).

On one system, I'm having no problems. On the other, the batch file keeps giving: 'mysqldump' is not recognized as an internal or external command, operable program, or batch file.

I dropped to DOS. The DOS window "knew" where mysqldump was, just fine. So, scratching my head, I went into IIS Manager and checked PHP. I used phpinfo() to look at the Path settings. They are NOT showing my addition of the mysql bin directory. So, I cycled the application pool. the sever (in the "tree" right above the app pool)... no change.

I really don't want to reboot the server if I don't have to, as it's a production server with people using it right now.

But I'm not sure what I need to do to get PHP to "take" that System Environment Variable / Path update. Any thoughts?

Was it helpful?

Solution

Try to set LoadUserProfile to True in the Application Pool that runs the PHP script.

OTHER TIPS

i just found the answer here: https://serverfault.com/a/193614/388136

basically, iis loads the environment variables on startup and never refreshes them, so if you've made changes you have to restart the service itself. the optimal way to do that is running iisreset from the command line

Something iis reset doesn't work or load profile true is on default. Most of the cases the path variable is not updating because php loads the path variables on its initial runtime. Something shutdown/ restarts fixes it but the optimal solution is:

  • Open task manager
  • Close all the php executables like php.exe and php-cli.
  • Go to your iis php directory and click on php.exe and php-cli or you can restart your computer this will open them again with the latest configs.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top