Apache configuration is configured in the httpd. conf file. Therefore, the following configuration commands are all modified in the httpd. conf file.
Configuration of the primary site (basic configuration)
Basic Configuration:
ServerRoot "/mnt/software/apache2" # location of your apache software installation. If no absolute path is specified for other specified directories, the directory is relative to this directory.
Listen 80 # Port Number of the server listener.
# You can set multiple port numbers.
ServerName www.test.com: 80 # main site name (website host name ).
ServerAdmin admin@test.com # administrator email address.
DocumentRoot "/mnt/web/test" # webpage storage location of the primary site.
Access Control for the Directory of the main site is as follows:
<Directory "/mnt/web/test">
Options FollowSymLinks
AllowOverride None
Order allow, deny
Allow from all
</Directory>
The preceding Directory attribute configuration mainly includes the following options:
Options: What features are used for configuration in a specific directory? common values and basic meanings are as follows:
FollowSymLinks: in this directory, the file system is allowed to use symbols to connect.
Indexes: if the user cannot find the main page file specified by directoryindex(for example, index.html), the list of files in the directory is returned to the user.
AllowOverride: indicates the type of the command that is allowed to exist in the. htaccess file. The file name of the. htaccess file can be changed. The file name is determined by the AccessFileName command ):
None: When AllowOverride is set to None. Do not search for. htaccess files in this directory (you can reduce the server overhead ).
All: All commands can be used in the. htaccess file.
Order: control which of the Allow and Deny access rules takes precedence during access:
Allow: List of hosts that can be accessed (available domain names or subnets, for example, Allow from 192.168.0.0/16 ).
Deny: List of Access Denied hosts.
DirectoryIndex index.html index.htm index. php # settings of the home page file (in this example, the home page file is set to index.html, index.htm and index. php)
Virtual Host Configuration
Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot/www/example1
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot/www/example2
ServerName www.example2.org
</VirtualHost>