Use command prompt to install the Apache service

Aug 25, 2007 08:31 GMT  ·  By

The easiest way to install Apache is as a service during the installation. But if you forgot to check that option or you don't want to install it as a service for all users, you may register Apache as a service only for you. Apache comes with a utility called the Apache Service Monitor. With it, you can see and manage the state of all installed Apache services on any machine on your network. To be able to manage an Apache service with the monitor, you have to first install the service.

Go to C:/Program Files/Apache Software Foundation/Apache2.2/bin and type: httpd -k install. If you have multiple instances of Apache installed on your computer, using httpd -k install -n "ServiceName" you can specify the name of the service you want to install. Also, if you want to specify the configuration file for your Apache service, use: httpd -k install -n "ServiceName" -f "C:/Program Files/Apache Software Foundation/Apache2.2/my.conf". If you don't use -k install, the service will be called Apache2 and the configuration file will be C:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf.

Uninstalling the Apache service is very easy: http -k uninstall. Also, if you want to uninstall a specific service of Apache, use: httpd -k uninstall -n "MyServiceName". To test the configuration file of the service, use: httpd -n "ServiceName" -t

You may start, restart, and stop the Apache service using the Apache Service Monitor. But you can do it from command prompt. To start the Apache service use : httpd -k start, to stop use httpd -k stop or httpd -k shutdown and if you need to restart the service, use httpd -k restart. Very easy and intuitive.

To test the installation, start your browser and type: http://127.0.0.1 and if you use another port, type http://127.0.0.1:8011/.