I've been struggling with Apache Virtualhost for a day now. I would like to run 2 sites with one ip.
When I enter the address in the url bar(domain1 or domain2), it always shows the default page only(which is domain1).
Any help will/would be appreciated...
My configuration :
/var/www/html:
domain1/public_html/index.html
domain2/public_html/index.html
/etc/apache2/sites-enabled:
├── domain1.conf -> ../sites-available/domain1.conf
└── domain2.conf -> ../sites-available/domain2.conf
domain2.conf :
<VirtualHost *:80>
ServerName www.domain1.tk
ServerAlias domain1.tk
DocumentRoot /var/www/html/domain1/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
domain2.conf :
<VirtualHost *:80>
ServerName domain2.tk
ServerAlias www.domain2.tk
DocumentRoot /var/www/html/domain2/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
apache2.conf :
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
apachectl -S– rda Jun 08 '16 at 10:06