简体   繁体   中英

Run a php file when Apache starts on xampp control panel, Is it possible?

Actually, I created a .php file where implemented all queries to update some status and want to run on apache startup(Apache start on xampp control panel). If it is possible, please tell me details about how to configure and where i have to change the settings to launch the php file..

Thnx

XAMPP comes with an apache_start.bat file in xampp's root directory. You can edit this file to include the following line ( save a backup copy of the .bat file before editing! ):

php -f  <path to your php script>

place that line before the line with apache\\bin\\httpd.exe , and your script will execute on apache restart.

If you haven't added PHP.exe to your environmental variables, you'll have to use the full path to PHP in the command. You should also provide the full path to your php script. For example:

c:\xampp\php\php.exe -f c:\xampp\htdocs\your-script.php
apache\bin\httpd.exe

If you run into problems try running your php script from the command line first, just to make sure that it works. It may take some experimentation to correctly set paths, and configure permissions depending on which version of Windows you're using.

Note that you'll have to run the .bat file to restart apache and execute your script. If you restart apache by clicking the start button in the XAMPP control panel it will ignore the .bat file and your script will not execute. (I'll update this answer if I figure out how to execute the script using the XAMPP control panel's start button)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM