Tuesday, June 23, 2009

Windows 管理 (manage) > 服務 裡面的東西,,像是裝 apache, mysql 後會出現在那

Windows 管理 (manage) > 服務 裡面的東西,,像是裝 apache, mysql 後會出現在那
那個叫做 service controller,可以用 start > run > cmd > sc.exe 來呼叫

因為米沙剛裝 MySQL 是用 "解壓縮直接用" 而不是 "安裝版" 的版本

所以在 我的電腦 > 右鍵 > 管理 > 服務 這裡面沒有 "MySQL"

要在這新增的方法是

把 CMD 打開,然後輸入

sc create MySQL555 binPath= "\"D:\uo\MySQL Server 5.0\bin\mysqld-nt\" --defaults-file=\"D:\uo\MySQL Server 5.0\my.ini\"" DisplayName= "MySQL555aaaaa"

我試了好陣子才試出來,注意:

1. 等號 = 後面有空格 ( 但參數後面的 等號 = 不用空格)
2. 路徑要用 \" \" 框起來

sc.exe 還有其它的功能 和 選項 / 參數等,有興趣的自己看看

ps. 以下是別人說得,正港把它貼上
上文有一個錯誤。
and you must NOT specify any other run mode
argument, such as --daemon, --tunnel, --inetd, or any of their short
forms. There is no short form for --service.

因此不能使用 -r 而應該用 --root
===============================================


Running Apache as a Service

Apache can be run as a service on Windows NT. There is some highly experimental support for similar behavior on Windows 9x.

You can install Apache as a service automatically during the installation. If you chose to install for all users, the installation will create an Apache service for you. If you specify to install for yourself only, you can manually register Apache as a service after the installation. You have to be a member of the Administrators group for the service installation to succeed.

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 (either automatically via the installation or manually).

You can install Apache as a Windows NT service as follows from the command prompt at the Apache bin subdirectory:

apache -k install

If you need to specify the name of the service you want to install, use the following command. You have to do this if you have several different service installations of Apache on your computer.

apache -k install -n "MyServiceName"

If you need to have specifically named configuration files for different services, you must use this:

apache -k install -n "MyServiceName" -f "c:\files\my.conf"

If you use the first command without any special parameters except -k install, the service will be called Apache2 and the configuration will be assumed to be conf\httpd.conf.

Removing an Apache service is easy. Just use:

apache -k uninstall

The specific Apache service to be uninstalled can be specified by using:

apache -k uninstall -n "MyServiceName"

Normal starting, restarting and shutting down of an Apache service is usually done via the Apache Service Monitor, by using commands like NET START Apache2 and NET STOP Apache2 or via normal Windows service management. Before starting Apache as a service by any means, you should test the service's configuration file by using:

apache -n "MyServiceName" -t

You can control an Apache service by its command line switches, too. To start an installed Apache service you'll use this:

apache -k start

To stop an Apache service via the command line switches, use this:

apache -k stop

or

apache -k shutdown

You can also restart a running service and force it to reread its configuration file by using:

apache -k restart

By default, all Apache services are registered to run as the system user (the LocalSystem account). The LocalSystem account has no privileges to your network via any Windows-secured mechanism, including the file system, named pipes, DCOM, or secure RPC. It has, however, wide privileges locally.
Never grant any network privileges to the LocalSystem account! If you need Apache to be able to access network resources, create a separate account for Apache as noted below.

No comments: