Modify installation directory parameters
First, check the 37 lines of the httpd. conf file.
ServerRoot "c:/Apache24"
Make the following changes based on the directory where Apache is installed.
ServerRoot "c:/MiddleWare/Apache24"
Also, modify the path near 242 rows, 359 rows, and 375 rows.
Before change (242 rows)
DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
After the change (242 rows)
DocumentRoot "c:/MiddleWare/Apache24/htdocs"
<Directory "c:/MiddleWare/Apache24/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Before change (359 rows)
ScriptAlias/cgi-bin/"c:/Apache24/cgi-bin /"
After the change (359 rows)
ScriptAlias/cgi-bin/"c:/MiddleWare/Apache24/cgi-bin /"
Before change (375 rows)
<Directory "c:/Apache24/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
After the change (375 rows)
<Directory "c:/MiddleWare/Apache24/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
Confirm the port used by Apache
Check that there are 58 lines near the httpd. conf file.
Listen 80
Port 80 is the default port of Apache. Generally, you do not need to modify the port number. However, if another application uses port 80, you must modify the port number.
Modify ServerName
Confirm the ServerName configuration for Row 3.
# ServerName www.example.com: 80
When it starts with #, this line is Annotated. It can be seen that the ServerName in the initial configuration file is invalid, but it is recommended to explicitly configure ServerName. For a public website, you must configure the domain name + Port. If the port is omitted, the Listen parameter is used. When running Apache locally, configure "localhost: 80" or "127.0.0.1: 80 」.
Perform the following configuration this time.
ServerName localhost: 80
After the httpd. conf file is configured, save it. You have completed the preparation before installing and running Apache.
Configure how to start Apache
Visit the service overview page. On Windows Server 2008, choose start> Administrative Tools> services 」. The default name after logging on to the service from Apache is "Apache2.4 」.
Double-click Apache2.4 to display Apache service-related properties.
The current "start type" is "automatic", which means that Apache is automatically started when the system is started. If you do not want to start Apache at startup, set "startup type" to "manual" when you manually start Apache as needed 」.
The current Apache is stopped. Click start to start Apache. You can also perform stop, pause, and resume operations. For example, the startup and stop operations described in Apache can also be performed on the command line.
1) start Apache through the command line
The first is to start Apache from the command line. The path for saving the execution file is "Apache installation directory \ Apache24 \ bi \ httpd.exe 」.
First, switch the directory to the directory where httpd.exe is stored and run the httpd command.
The command line page for running Apache is as follows.
Check whether Apache is running normally. Open the browser and enter "http: // localhost/". The following page appears, indicating that Apache is running properly.
When you stop Apache, enter Ctrl + C in the command line. The following figure shows that Apache is stopped.
2) start Apache as a Service
When starting Apache as a service, you need to log on to the service. If Apache is in the startup status, stop Apache, switch to the bin directory where Apache is installed, and run the "httpd-k install" command.
As shown below, it means to log on to the service by using Apache. However, only one operation is required to log on to the service.
Start Apache and run the "httpd-k start" command. If Apache is started normally, the command line is in the writable state.
Check whether Apache is started. Open the browser and enter "http: // localhost/". If the page is displayed, Apache is successfully started.
When you stop Apache started as a service, run "httpd-k stop" or "httpd-k shutdown" on the command line 」.
When you restart Apache, run "httpd-k restart" on the command line 」.
Delete Apache from service
You need to run "httpd-k uninstall" when you delete Apache from the service 」.
Now, we have introduced you to apache installation service configuration and startup. I hope this tutorial will help you.