Underground Forum
- #1
Apache2, adding new domain
In order to bind a domain(s) or subdomains to your httpd server, you will need to edit the configuration file.
But keep in mind that you will also need to set up DNS on the side of the domain registrar, otherwise no one will see your site.
Where to find VirtualHost settings in Apache
On Ubuntu OS, the virtual host configuration is located in the directory/etc/apache2/sites-available
. Other, similar operating systems have virtualhost settings right in the apache2.conf file.On CentOS, virtualhost settings can be found in the main configuration file httpd.conf located at
/etc/httpd/conf/httpd.conf
.Use the <VirtualHost * :80> container to add a new virtualhost. You can add as many as you like.
Configure container VirtualHost * :80
# First domain (VirtualHost)
<VirtualHost *:80> # Tag denoting virtual host settings, 80 is the port
ServerAdmin user1@domain1.com # Administrator's contact address
DocumentRoot /var/www/domain1.com # Website's directory
ServerName domain1.ru # Domain name
ServerAlias www.user1domain1.com # Alternative names
ErrorLog logs/user1domain1.com-error_log # Logs
CustomLog logs/user1domain1.com-access_log common # Logs
<Directory /> # Defines the rules for a directory
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
# Second domain (VirtualHost)
<VirtualHost *:80>
ServerAdmin user2@domain2.com
DocumentRoot /var/www/html/user2.domain2.com
ServerName user2.domain2.com
ErrorLog logs/user2.domain2.com-error_log
CustomLog logs/user2.domain2.com-access_log common
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>