Home > Articles > Software Development & Management

  • Print
  • + Share This
  • 💬 Discuss
This chapter is from the book

This chapter is from the book

Microsoft Windows

As should be expected, Microsoft Windows does things a little differently. Apache on Windows offers a few other ways to manage things, more in line with the expected Windows way of doing things. For example, you can install Apache as an NT service, or start and stop it from the Start menu. However, there are also several ways to start and stop Apache from the command line as well.

Starting from the Command Line

The various command-line options previously listed for httpd also work on Windows, except that the executable on Windows is called apache, and is (by default) located in c:\program files\apache group

cd "\program files\apache group"
apache

After doing this, you might need to press control-C to regain control of your command prompt. Apache will continue running. Make sure that you can start Apache in this manner and that it is serving pages correctly before you proceed to the next step, to ensure that things are mostly set up OK.

Installing as a Service

As previously described, if you are running a production server, you'll want to install Apache as a service. This is done with the following commands.

To install Apache as a service with no special options, do the following:

apache -k install -n "service name"

If the "service name" option is omitted, the service name "Apache" is used as the default name of the service.

If you want to install the service to use a particular configuration file, different from the default location for configuration files that you specified during the installation process, you can specify a different configuration file when you install the service. This way, you can have multiple Apache services, with different configurations.

apache -k install -n "service name" -f "\path\to\alternate\conf"

To remove the Apache service after it is installed, you can use the following command:

apache -k uninstall -n "service name"

Starting and Stopping Your Apache Service

After you have Apache installed as an NT service, you can start and stop it a number of different ways.

apache -n "service name"

You can call the Apache binary directly from the command line if you like, passing it arguments as we discussed previously with httpd. To start, restart, or stop the Apache service, you would use the following three commands, respectively:

apache -n "service name" start
apache -n "service name" restart
apache -n "service name" shutdown

Where, in each case, "service name" is whatever you called the service when you installed it.

NT NET Command

Alternatively, you can use the NT NET command, which can start and stop any NT service:

NET START "service name"
NET STOP "service name"

Services Control Panel

Finally, there's the NT GUI (graphical user interface) way to do things. NT provides you with a Services dialog, which lists all of the NT services, and enables you to start and stop each one. Additionally, it enables you to set properties on each service, such as whether they start automatically on server boot.

The Services applet is located in the Control Panel.

Console Application

Under Windows 9x (Windows 95, Windows 98, and Windows ME), Apache does not, by default, run as a service. Windows 9x, not being server operating systems, do not have the concept of a service.4

Consequently, under Windows 9x, Apache runs as a console application. Which means, as it sounds, that Apache runs in a console (DOS window), and that console stays open for the entirety of the time that Apache is running. This is a little less than convenient, but then you really should not be using Windows 9x as a server platform, so hopefully this will only inconvenience you during testing.

If you are running Apache as a console application, you will launch it from the Start menu, in the Apache submenu. This will open up a console in which you will see an indication that Apache is running. To shutdown Apache, or restart it, the recommended method is to open another console, and type the commands

apache -k shutdown

to shutdown the process, and

apache -k restart

to restart it.

Doing this with the -k option, rather than just pressing control-C in the console window, or just closing the console window, is preferable, because it enables Apache to shutdown cleanly, rather than abruptly disconnecting from any open connections. However, because you are hopefully not running this in a server environment, it probably does not matter much.

Summary

Apache provides a variety of ways to start, stop, and restart your server. This makes it easy to automate these processes, and ensure that your server is always running when it needs to be.

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus