Tuesday, July 22, 2008

Installing MySQL and Apache as Windows services

To install Apache as a service

From the Apache bin directory (usually C:\Program Files\Apache Group\Apache2\bin):
C:\Program Files\Apache Group\Apache2\bin>Apache.exe -k install -n "This is the service name"
Other options are
-k uninstall to uninstall the service,
-k start,
-k stop and
-k restart to control the apache server.

To install MySQL as a service

From the MySQL bin directory (usually C:\Program Files\MySQL\MySQL Server 5.0\bin):
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysqld --install "This is the service name" --defaults-file=C:/custom/path/to/my.ini
The example above sets the --defaults-file option which allows you to specify a non-standard options file location. The server will read options from the [mysqld] group.

To control the server you can use mysqladmin --port=3306 -u root shutdown to shutdown the server. 3306 is the default port. I put in the --port option as an example for when you need to specify a non-standard port. mysqld --remove removes the service. There are many other useful commands, to see them use the --help option.

No comments: