Check the syntax of the httpd.conf configuration file
If there is a syntax error in the configuration file httpd.conf , the apache service cannot be started. Therefore, do a syntax check on httpd.conf before starting apache .
In the DOS command, using httpd.exe - t to httpd.conf file syntax checking
Note: After the configuration file httpd.conf is modified, the apache service must be restarted , otherwise, the modified content will not take effect.
After the modification of the hosts file, there is no need to restart the operating system, it takes effect immediately.
W indows configure the system environment variables
Right-click on "My Computer"-Properties-Advanced System Settings-"Advanced" tab-"Environment Variables" button-System Variables- path options
Special attention: When setting the system environment variables, you must be careful. If the operation fails, it will cause the entire window system to fail to start.
In the value of Path , each path must be separated by a semicolon (;) under English .
I added two paths above, one is the main program directory of apache , and the other is the directory of the main program of MySQL
If the following error occurs, it means that the main program directory of apache is not specified
Apache global configuration
1. DocumentRoot Command
Meaning: Set the virtual directory of the website ( website root directory )
Example: DocumentRoot " e: \ www "
Note: Chinese characters cannot appear on all paths in the configuration file
If you enter localhost / images / img01.png in the address bar , what is the actual path you point to?
Actual path: e: \ www \ images \ img01.png
localhost stands for DocumentRoot .
127.0.0.1 stands for DocumentRoot
192.168.3.100 stands for DocumentRoot
Second, the ServerRoot command
Meaning: Set the Apache installation directory, this directory generally does not need to be modified
举例:ServerRoot "C:/Program Files (x86)/phpStudy/Apache2"
The following command is to set the storage location of the access log, but it uses quite the path, relative to ServerRoot .
CustomLog "logs/access.log" common
Three, Listen command
Meaning: When Apache starts, it will bind the local IP address ( own IP address ) and port number, waiting for the request to enter.
Format: Listen IP address [IP address and port number ] [ port number ]
For example: the Listen 80 // listen to all IP 's 80 -port
Listen 192.168.3.100:80 // listening 192.168.3.100 of 80 ports
Listen 192.168.3.100 // Listen to requests from all ports of 192.168.3.100
Understand: The port of the computer can be about 65536 ports.
Port 80 provides WWW service. Port 80 is the default port.
Port 21 provides FTP service ( upload and download files ) . For example: FlashFXP , leapFTP website file maintenance FTP software
A computer can have multiple IP addresses, and the IP address can be set in the network card.
Four, DirectoryIndex command
Meaning: The setting of the default homepage, multiple homepage file names are separated by spaces
举例:DirectoryIndex index.html index.php default.html default.php
Priority of multiple homepage files: the previous priority is the highest
Note: If no home page file is specified, the list of files in the website will be displayed directly, which is not good for website security.
Five, <Directory> </ Directory> command
Meaning: Set the access rights of the virtual directory
format:
<Directory “e:\www”>
Options Indexes
Order deny,allow
Deny from All
Allow from 192.168.3.200
</Directory>
Parameter Description:
Options to open the characteristics of the server, values: Indexes , none , All
Indexes : If the home page file does not exist (DirectoryIndex is not set ) , display the file list
None : no server features are open
All : All server features are open
The meaning of the picture above: You do not have permission to access this server
Order : Specify (deny) the order of disabling and allowing ( such as: Order Deny, Allow)
Deny : Set an IP address that prohibits access or prohibit all
Deny from 192.168.3.200 192.168.3.45
Allow from 192.168.3 // Allow 256 computers behind 192.168.3 to access my host