Apache 2.0.63
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:
Note: httpd = Apache.exe
httpd -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.
httpd -k install -n "MyServiceName"
If you need to have specifically named configuration files for different services, you must use this:
httpd -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:
httpd -k uninstall
The specific Apache service to be uninstalled can be specified by using:
httpd -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:
httpd -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:
httpd -k start
To stop an Apache service via the command line switches, use this:
httpd -k stop
or
httpd -k shutdown
You can also restart a running service and force it to reread its configuration file by using:
httpd -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.
You may want to create a separate account for running Apache service(s). Especially, if you have to access network resources via Apache, this is strongly recommended.
1. Create a normal domain user account, and be sure to memorize its password.
2. Grant the newly-created user a privilege of Log on as a service and Act as part of the operating system. On Windows NT 4.0 these privileges are granted via User Manager for Domains, but on Windows 2000 and XP you probably want to use Group Policy for propagating these settings. You can also manually set these via the Local Security Policy MMC snap-in.
3. Confirm that the created account is a member of the Users group.
4. Grant the account read and execute (RX) rights to all document and script folders (htdocs and cgi-bin for example).
5. Grant the account change (RWXD) rights to the Apache logs directory.
6. Grant the account read and execute (RX) rights to the Apache.exe binary executable
There are some differences between the two kinds of services you should be aware of:
• Apache will attempt to start and if successful it will run in the background. If you run the command
httpd -n "MyServiceName" -k start
via a shortcut on your desktop, for example, then if the service starts successfully, a console window will flash up but it immediately disappears. If Apache detects any errors on startup such as incorrect entries in the httpd.conf configuration file, the console window will remain visible. This will display an error message which will be useful in tracking down the cause of the problem.
• Windows 9x does not support NET START or NET STOP commands. You must control the Apache service on the command prompt via the -k switches.
Running Apache as a Console Application
Running Apache as a service is usually the recommended way to use it, but it is sometimes easier to work from the command line (on Windows 9x running Apache from the command line is the recommended way due to the lack of reliable service support.)
To run Apache from the command line as a console application, use the following command:
httpd
Apache will execute, and will remain running until it is stopped by pressing Control-C.
You can also run Apache via the shortcut Start Apache in Console placed to Start Menu --> Programs --> Apache HTTP Server 2.0.xx --> Control Apache Server during the installation. This will open a console window and start Apache inside it. If you don't have Apache installed as a service, the window will remain visible until you stop Apache by pressing Control-C in the console window where Apache is running in. The server will exit in a few seconds. However, if you do have Apache installed as a service, the shortcut starts the service. If the Apache service is running already, the shortcut doesn't do anything.
You can tell a running Apache to stop by opening another console window and entering:
httpd -k shutdown
This should be preferred over pressing Control-C because this lets Apache end any current operations and clean up gracefully.
You can also tell Apache to restart. This forces it to reread the configuration file. Any operations in progress are allowed to complete without interruption. To restart Apache, use:
httpd -k restart
Note for people familiar with the Unix version of Apache: these commands provide a Windows equivalent to kill -TERM pid and kill -USR1 pid. The command line option used, -k, was chosen as a reminder of the kill command used on Unix.
If the Apache console window closes immediately or unexpectedly after startup, open the Command Prompt from the Start Menu --> Programs. Change to the folder to which you installed Apache, type the command apache, and read the error message. Then change to the logs folder, and review the error.log file for configuration mistakes. If you accepted the defaults when you installed Apache, the commands would be:
c:
cd "\Program Files\Apache Group\Apache2\bin"
httpd
Then wait for Apache to stop, or press Control-C. Then enter the following:
cd ..\logs
more < error.log
When working with Apache it is important to know how it will find the configuration file. You can specify a configuration file on the command line in two ways:
• -f specifies an absolute or relative path to a particular configuration file:
httpd -f "c:\my server files\anotherconfig.conf"
or
httpd -f files\anotherconfig.conf
• -n specifies the installed Apache service whose configuration file is to be used:
httpd -n "MyServiceName"
In both of these cases, the proper ServerRoot should be set in the configuration file.
If you don't specify a configuration file with -f or -n, Apache will use the file name compiled into the server, such as conf\httpd.conf. This built-in path is relative to the installation directory. You can verify the compiled file name from a value labelled as SERVER_CONFIG_FILE when invoking Apache with the -V switch, like this:
httpd -V
Testing the Installation
After starting Apache (either in a console window or as a service) it will be listening on port 80 (unless you changed the Listen directive in the configuration files or installed Apache only for the current user). To connect to the server and access the default page, launch a browser and enter this URL:
http://localhost/
Apache should respond with a welcome page and a link to the Apache manual. If nothing happens or you get an error, look in the error.log file in the logs subdirectory. If your host is not connected to the net, or if you have serious problems with your DNS (Domain Name Service) configuration, you may have to use this URL:
http://127.0.0.1/
If you happen to be running Apache on an alternate port, you need to explicitly put that in the URL:
http://127.0.0.1:8080/
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:
Note: httpd = Apache.exe
httpd -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.
httpd -k install -n "MyServiceName"
If you need to have specifically named configuration files for different services, you must use this:
httpd -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:
httpd -k uninstall
The specific Apache service to be uninstalled can be specified by using:
httpd -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:
httpd -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:
httpd -k start
To stop an Apache service via the command line switches, use this:
httpd -k stop
or
httpd -k shutdown
You can also restart a running service and force it to reread its configuration file by using:
httpd -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.
You may want to create a separate account for running Apache service(s). Especially, if you have to access network resources via Apache, this is strongly recommended.
1. Create a normal domain user account, and be sure to memorize its password.
2. Grant the newly-created user a privilege of Log on as a service and Act as part of the operating system. On Windows NT 4.0 these privileges are granted via User Manager for Domains, but on Windows 2000 and XP you probably want to use Group Policy for propagating these settings. You can also manually set these via the Local Security Policy MMC snap-in.
3. Confirm that the created account is a member of the Users group.
4. Grant the account read and execute (RX) rights to all document and script folders (htdocs and cgi-bin for example).
5. Grant the account change (RWXD) rights to the Apache logs directory.
6. Grant the account read and execute (RX) rights to the Apache.exe binary executable
There are some differences between the two kinds of services you should be aware of:
• Apache will attempt to start and if successful it will run in the background. If you run the command
httpd -n "MyServiceName" -k start
via a shortcut on your desktop, for example, then if the service starts successfully, a console window will flash up but it immediately disappears. If Apache detects any errors on startup such as incorrect entries in the httpd.conf configuration file, the console window will remain visible. This will display an error message which will be useful in tracking down the cause of the problem.
• Windows 9x does not support NET START or NET STOP commands. You must control the Apache service on the command prompt via the -k switches.
Running Apache as a Console Application
Running Apache as a service is usually the recommended way to use it, but it is sometimes easier to work from the command line (on Windows 9x running Apache from the command line is the recommended way due to the lack of reliable service support.)
To run Apache from the command line as a console application, use the following command:
httpd
Apache will execute, and will remain running until it is stopped by pressing Control-C.
You can also run Apache via the shortcut Start Apache in Console placed to Start Menu --> Programs --> Apache HTTP Server 2.0.xx --> Control Apache Server during the installation. This will open a console window and start Apache inside it. If you don't have Apache installed as a service, the window will remain visible until you stop Apache by pressing Control-C in the console window where Apache is running in. The server will exit in a few seconds. However, if you do have Apache installed as a service, the shortcut starts the service. If the Apache service is running already, the shortcut doesn't do anything.
You can tell a running Apache to stop by opening another console window and entering:
httpd -k shutdown
This should be preferred over pressing Control-C because this lets Apache end any current operations and clean up gracefully.
You can also tell Apache to restart. This forces it to reread the configuration file. Any operations in progress are allowed to complete without interruption. To restart Apache, use:
httpd -k restart
Note for people familiar with the Unix version of Apache: these commands provide a Windows equivalent to kill -TERM pid and kill -USR1 pid. The command line option used, -k, was chosen as a reminder of the kill command used on Unix.
If the Apache console window closes immediately or unexpectedly after startup, open the Command Prompt from the Start Menu --> Programs. Change to the folder to which you installed Apache, type the command apache, and read the error message. Then change to the logs folder, and review the error.log file for configuration mistakes. If you accepted the defaults when you installed Apache, the commands would be:
c:
cd "\Program Files\Apache Group\Apache2\bin"
httpd
Then wait for Apache to stop, or press Control-C. Then enter the following:
cd ..\logs
more < error.log
When working with Apache it is important to know how it will find the configuration file. You can specify a configuration file on the command line in two ways:
• -f specifies an absolute or relative path to a particular configuration file:
httpd -f "c:\my server files\anotherconfig.conf"
or
httpd -f files\anotherconfig.conf
• -n specifies the installed Apache service whose configuration file is to be used:
httpd -n "MyServiceName"
In both of these cases, the proper ServerRoot should be set in the configuration file.
If you don't specify a configuration file with -f or -n, Apache will use the file name compiled into the server, such as conf\httpd.conf. This built-in path is relative to the installation directory. You can verify the compiled file name from a value labelled as SERVER_CONFIG_FILE when invoking Apache with the -V switch, like this:
httpd -V
Testing the Installation
After starting Apache (either in a console window or as a service) it will be listening on port 80 (unless you changed the Listen directive in the configuration files or installed Apache only for the current user). To connect to the server and access the default page, launch a browser and enter this URL:
http://localhost/
Apache should respond with a welcome page and a link to the Apache manual. If nothing happens or you get an error, look in the error.log file in the logs subdirectory. If your host is not connected to the net, or if you have serious problems with your DNS (Domain Name Service) configuration, you may have to use this URL:
http://127.0.0.1/
If you happen to be running Apache on an alternate port, you need to explicitly put that in the URL:
http://127.0.0.1:8080/
No comments:
Post a Comment