I have a goal to host few websites as subdomains.(Apache2 at Ubuntu 18.04 at Google Cloud Platform) Directories:
/var/www/domain.com/public_html
- main directory for real registered domain
my subdomains
/var/www/test1.domain.com/public_html
/var/www/test2.domain.com/public_html
/var/www/test3.domain.com/public_html
Access to subdomains by address test(1,2,3).domain.com
I'm new with Apache2 so it's possibe I want something unreal or use Apache2 in wrong way. If so could you show my mistakes?
I tried to configure Virtual hosts but unsuccessful. Maybe it is possible make it via htaccess?
domain.com.conf
<VirtualHost *:80>
ServerAdmin admin@mail.com
DocumentRoot /var/www/domain.com/public_html
ServerName domain.com
ServerAlias www.domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
test1.domain.com.conf
<VirtualHost *:80>
ServerAdmin admin@mail.com
DocumentRoot /var/www/test1.domain.com/public_html
ServerName test1.domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The trouble was not in Apache configuration. It was correct. If you will have the same goal as mine, first of all you need
And only then configure Apache webserver.