Question
Problem with multiple subdomains-DocumenRoots on Ubuntu 18.04 and Apache2
Hi guys,
I apologize if this is a duplicated question, I have been trying to find an answer through the related posts I have managed to find with no luck so far…
I have an apache2 server running on Ubuntu 18.04 (DNS for DigitalOcean set) with two subdomains: php.example.com and blog.example.com (DNS A Records set for the droplet IP). I installed phpMyAdmin (/usr/share/phpmyadmin) and a wordpress blog (/var/www/wordpress).
I wanted to access phpMyAdmin through php.example.com and the blog through blog.example.com / www.example.com but I cannot get to it; all the subdomains go to one of the DocumentRoots.
I have followed some tutorials (https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04) and tips I have seen here and on different sites, and so far I have completed these steps:
1) Configured Virtual Hosts:
wordpress.conf:
<VirtualHost *:80>
ServerAdmin example@mail.com
ServerName www.example.com
ServerAlias blog.example.com
DocumentRoot /var/www/wordpress
<Directory /var/www/wordpress/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin example@mail.com
ServerName www.example.com
ServerAlias blog.example.com
DocumentRoot /var/www/wordpress
SSLEngine on
SSLCertificateFile /certroute
SSLCertificateKeyFile /keyroute
SSLCertificateChainFile /chainroute
<Directory /var/www/wordpress/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
phpmyadmin.conf:
<VirtualHost *:80>
ServerAdmin example@mail.com
ServerName php.example.com
DocumentRoot /var/www/phpmyadmin
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin example@mail.com
ServerName php.example.com
DocumentRoot /var/www/phpmyadmin
SSLEngine on
SSLCertificateFile /certroute
SSLCertificateKeyFile /keyroute
SSLCertificateChainFile /chainroute
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
2) Enabled both .conf files and disabled 000-default.conf / default-ssl.conf
3) Set up a symlink from /var/www/phpmyadmin to /usr/share/phpmyadmin
4) Reloaded Apache2
Still going to wordpress when I try to load https://php.example.com and at this point I really don’t know what to try next.
Any help would be much appreciated.
Thanks!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×