config centos httpd to multi site
To configure Apache HTTP Server (httpd) on CentOS to support multiple websites, you can use the VirtualHost directive in the Apache configuration file.
The VirtualHost directive allows you to specify a separate configuration for each website, such as the server name, the document root, the log files, and the virtual aliases.
To configure Apache HTTP Server on CentOS to support multiple websites, follow these steps:
- Open the Apache configuration file, which is typically located at
/etc/httpd/conf/httpd.conf, using a text editor, such asviornano. - Locate the
VirtualHostdirective and add a separateVirtualHostblock for each website you want to host. For example:
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/html/example.com
ErrorLog /var/log/httpd/example.com-error.log
CustomLog /var/log/httpd/example.com-access.log common
</VirtualHost>
<VirtualHost *:80>
ServerName www.anothersite.com
DocumentRoot /var/www/html/anothersite.com
ErrorLog /var/log/httpd/anothersite.com-error.log
CustomLog /var/log/httpd/anothersite.com-access.log common
</VirtualHost>
- Save the configuration file and exit the text editor.
- Restart the Apache HTTP Server using the following command:
sudo systemctl restart httpd
After completing these steps, Apache HTTP Server will be configured to support multiple websites, and you can access each website using its corresponding server name.