-
Download and install the PHP package, if necessary.
We have installed PHP in C:\PHP and we'll reference that location throughout this tutorial.
-
Next, please ensure that your PHP script can run normally from the command line.
-
Start a command prompt (Start button > Run > cmd.exe)
-
In the window that appears, type the full path to the PHP executable (php.exe) followed by the full path to the script you wish to run as a windows service. Be sure to quote each component containing at least one space!
Since we have placed PHP in C:\PHP, and our script is C:\PHP\sample-php-script.php, our command line is:
C:\PHP\php.exe C:\PHP\sample-php-script.php
-
Hit the Enter key to execute the command line. If your script doesn't work as expected please resolve the issues now.
Note that if your script doesn't work here then it won't work with AlwaysUp!
Here's the code of our simple script:
And here is the result from running it on the command line:
Everything looks good!
-
Next, start AlwaysUp.
-
Select Application > Advisor to launch the Application Advisor:
-
Click Next to get started:
-
Choose PHP from the list of applications and click Next:
-
The Advisor will spend a few seconds gathering information about your PHP installation.
Afterwards, enter the full path to your PHP executable (php.exe) and click Next to move on:
-
Enter the full path to the PHP script you would like to run and click Next to continue:
-
For best results, PHP should run in an account where have run it successfully. Enter the
user name and password of your Windows account and click Next to continue:
-
We're almost done! Click Next to continue:
-
The Add Application window contains all the recommended settings for running your PHP script 24x7 after your PC boots.
If you are curious, you can cycle through the tabs and review the options that have been chosen.
Click Save to record your new PHP service:
-
This next window provides guidance if you want your script to run periodically (that is, not 24x7).
If that is the case, this article
may be helpful too.
Click Done when you are ready to move on.
-
A new entry for your PHP script will appear in the AlwaysUp window.
However, the state will be "Stopped" because the service and your script are not yet running:
-
To start the service, which will kick off the PHP script, choose Application > Start "PHP:...".
In a few seconds, the state will transition to "Running":
-
That's it! Next time your computer boots, your PHP script/service will be launched immediately, before anyone logs on.
We encourage you to edit the entry in AlwaysUp and check out the full complement of settings that
may be appropriate for your environment.
For example, you can boost the priority of the PHP process, monitor the executable for excessive CPU usage,
configure a weekly report, and much more.