I have created a new MySQL droplet (using the DO MySQL marketplace image) which comes preconfigured with a default web page which seems to work fine. I now want to assign a subdomain name (e.g., db.example.com) to this server. I had the impression the only thing I needed to do are the following steps:
ServerName db.example.com
to /etc/apache2/sites-available/000-default.conf
inside section <VirtualHost *:80>
a2ensite db.example.com
systemctl reload apache2
Unfortunately, that did not work. When I enter apachectl configtest
the following message is displayed:
AH00558: apache2: Could not reliably determine the server's fully qualified
domain name, using 127.0.1.1. Set the 'ServerName' directive globally to
suppress this message
That sounds like Apache doesn’t see my ServerName line in file 000-default.conf
, which I don’t understand. So, I added the ServerName db.example.com
line to the apache2.conf
file as the message suggests. apachectl configtest
now shows “Syntax OK”, but when I enter a2ensite db.example.com
it displays:
ERROR: Site db.example.com does not exist!
Does anyone see what I’m doing wrong?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Hi @JigsawBob,
What I’ll recommend is creating another configuration file rather than using the 000-default.conf one.
Create the directory for your_domain as follows:
Next, assign ownership of the directory with the $USER environment variable:
The permissions of your web roots should be correct if you haven’t modified your unmask value, but you can make sure by typing:
In order for Apache to serve this content, it’s necessary to create a virtual host file with the correct directives. Instead of modifying the default configuration file located at /etc/apache2/sites-available/000-default.conf directly, let’s make a new one at /etc/apache2/sites-available/your_domain.conf:
Paste in the following configuration block, which is similar to the default, but updated for our new directory and domain name:
Remember to change all occurrences of your_domain with your actual domain name!
Let’s enable the file with the a2ensite tool:
Disable the default site defined in 000-default.conf:
Next, let’s test for configuration errors:
You should see the following output:
Restart Apache to implement your changes:
Regards, KFSys
I’m using DO’s MySQL marketplace image because the server is to be used as a separate, dedicated DB server to my web server. I don’t want to use the DB server for general web traffic, but I do want to be able to access the built-in PhpMyAdmin panel with a secure SSL browser connection. That’s the only reason I’m setting up a domain (actually a subdomain of the web server’s domain) on the DB server. I’ve got it working now, so I will share what I did in case anyone else needs a minimal list of steps to setup a secure PhpMyAdmin connection to your Ubuntu MySQL server:
Create a DNS A record for a new subdomain (e.g., db.example.com) that points to the IP address of your DB server. Then open an SSH root user session to the DB server to complete the remaining steps.
Create directory
/var/www/ssl
and place the domain’s SSL cert and key files in it (e.g.,example.com.pem
andexample.com.key
). I’m assuming your example.com SSL cert is a wildcard cert, in which case you can simply use your existing SSL cert and key files. Otherwise, you will need to create SSL cert and key files specific to subdomain db.example.com and use those.Enter
chown -R ww-data:www-data /var/www/ssl
so Apache owns the SSL files.Create file
/etc/apache2/sites-available/db.example.com.conf
and give it the following contents (adjust as needed):Enter
chown -R ww-data:www-data /etc/apache2/sites-available/db.example.com.conf
so Apache owns the new conf file.Enter
a2enmod ssl
to enable SSL.Enter
a2ensite db.example.com
to enable the subdomain in Apache.Enter
systemctl restart apache2
to restart Apache.That’s it! You should now be able to securely access the PhpMyAdmin panel by going to
https://db.example.com/phpmyadmin
.