This article describes how to bind a domain name to Apache under centos and to multiple domain names to Apache. First, find the location of the Apache configuration file httpd. conf. The centos operating system is generally in/etc/httpd/CONF. Some Linux operating systems are in the/etc/apache2/conf or/usr/local/etc/Apache folder, the remaining thing to do is to modify the configuration file httpd. conf. Generally, the following domain name binding instructions are provided at the bottom of the configuration file:
- # VirtualHost example:
- # Almost any Apache directive may go into a VirtualHost container.
- # The first VirtualHost section is used for requests without a known
- # server name.
- #
- #<VirtualHost *:80>
- # ServerAdmin [email protected]
- # DocumentRoot /www/docs/dummy-host.example.com
- # ServerName dummy-host.example.com
- # ErrorLog logs/dummy-host.example.com-error_log
- # CustomLog logs/dummy-host.example.com-access_log common
- #</VirtualHost>
You can also add your own configuration instructions based on the relevant syntax. The following is the configuration file of my carefree program: 1. * change the asterisk to the IP address of your website. 2. serveradmin administrator email address (optional) 3. the DocumentRoot website file is located in the directory path of the server. 4. servername is bound to the corresponding domain name. 5. serveralias wildcard DNS is bound to the sub-domain name. 6. errorlog and customlog are used to specify the log file storage path.
- <VirtualHost 175.102.8.117:80>
- addDefaultCharset gbk
- DocumentRoot /chengxu
- ServerName 66php.com
- ServerAlias *.66php.com
- ErrorLog /sym/logs/66php.com-error_log
- CustomLog /sym/logs/66php.com-access_log common
- </VirtualHost>
If a server is bound with multiple domain names instead of adding multiple domain names to servername, only one domain name can be added to the server name. To bind multiple domain names, you must add multipleVirtualhostModule.