Wednesday, September 24, 2014

How to create service for apache webserver in windows manually


Incase if you have not chosen "Add as a service" option during the Apache or IHS installation, Then you will have to add the Apache service manually to the windows services. This would start and stop the webserver automatically during the windows reboot.

Following steps will guide you to manually create a service for apache webserver in windows.

Commands:

To create a service:

Syntax:  sc <server> create [service name] [binPath= ] <option1> <option2> ..

sc.exe create "servicename" binPath= "E:\bin\httpd -k runservice" DisplayName= "somename" start= auto

ex: sc.exe create apacheservice binPath= "E:\bin\httpd -k runservice" DisplayName= "Apacheservice" start= auto

Following message will indicate a successful service creation.

[SC] CreateService SUCCESS

NOTE: Ensure that there is a space after the "=" symbol or else the command will fail. Following message will be displayed in case of wrong syntax.


To Delete a service:  

sc.exe delete apacheservice 

[SC] DeleteService SUCCESS 

Testing:

go to run prompt, type service.msc. The newly created service will be visible. You can right click and change the properties, start and stop the service.

This similar exercise can be used for other services as well, Only the command will differ. 

                                 (: Happy learning :)


0 comments:

Post a Comment