Run any PHP Script as a Windows Service with AlwaysUp

How to Run any PHP Script as a Windows Service with AlwaysUp

Start your PHP script automatically in the background when your PC boots. Keep it running 24/7 or schedule it to restart several times a day


Last Updated on April 23, 2026

PHP is a popular programming language. It's often integrated with web servers but works just as well to create standalone applications.

In this step-by-step guide, we'll show you how to treat your PHP scripts like first class programs that run all the time — despite logons, logoffs and unexpected reboots.


To install and run your PHP script as a Windows Service with AlwaysUp:

  1. Download and install the PHP package, if necessary.

    Note that we installed PHP in "C:\PHP" and we'll reference that location throughout this tutorial.

  2. Next, please ensure that your PHP script can run normally from the command line. To do so:

    1. Start a command prompt (Start button > Run > cmd.exe)

    2. 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 that contains a space.

      Since we 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
    3. Hit the Enter key to execute the command line. If your script doesn't work as expected please resolve the issues now. Otherwise, it won't work as a Windows Service either.

      Here's the code of our simple script:

      Sample PHP script code

      And here is the result from running it on the command line:

      Sample PHP script code running

      Everything looks good!

  3. Next, start AlwaysUp.

  4. Select Application > Advisor to launch the Application Advisor:

    Start Application Advisor

  5. Click Next to get started:

    Application Advisor: Introduction

  6. Choose PHP from the list of applications and click Next:

    Application Advisor: Select PHP

  7. 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:

    PHP Windows Service: Enter the full path to PHP.EXE

  8. Enter the full path to the PHP script you would like to run and click Next to continue:

    PHP Windows Service: Enter the .PHP script file

  9. 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:

    PHP Windows Service: Enter your password

  10. We're almost done! Click Next to continue:

    Application Advisor: Ready to add PHP

  11. 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:

    Save your PHP service

  12. 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.

    PHP service: Don't run 24/7

  13. 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:

    PHP Windows Service: Installed

  14. 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":

    PHP Windows Service: Running

  15. 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:


PHP Script not working properly as a Windows Service?

  • Consult the AlwaysUp Troubleshooter — our online tool that can help you resolve the most common problems encountered when running an application as a Windows Service.

  • From AlwaysUp, select Application > Report Activity > Today to bring up an HTML report detailing the interaction between AlwaysUp and your PHP script. The AlwaysUp Event Log Messages page explains the more obscure messages.

  • Browse the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.

  • Contact us and we will be happy to help!

Our 14,000+ customers include...
AlwaysUp is fully compatible with Windows 11 AlwaysUp is fully compatible with Windows Server 2025
Over 97,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 20+ years!