Simple Apache question...

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., to this server. I had the impression the only thing I needed to do are the following steps:

  • Set a DNS A record to point to the server’s IP address
  • Add line ServerName to /etc/apache2/sites-available/000-default.conf inside section <VirtualHost *:80>
  • Enter a2ensite
  • Enter 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 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 line to the apache2.conf file as the message suggests. apachectl configtest now shows “Syntax OK”, but when I enter a2ensite it displays:

ERROR: Site does not exist!

Does anyone see what I’m doing wrong?

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

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:

sudo mkdir /var/www/your_domain

Next, assign ownership of the directory with the $USER environment variable:

sudo chown -R $USER:$USER /var/www/your_domain

The permissions of your web roots should be correct if you haven’t modified your unmask value, but you can make sure by typing:

sudo chmod -R 755 /var/www/your_domain

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:

sudo nano /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:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName your_domain
    ServerAlias www.your_domain
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Remember to change all occurrences of your_domain with your actual domain name!

Let’s enable the file with the a2ensite tool:

sudo a2ensite your_domain.conf

Disable the default site defined in 000-default.conf:

sudo a2dissite 000-default.conf

Next, let’s test for configuration errors:

sudo apache2ctl configtest

You should see the following output:

Syntax OK

Restart Apache to implement your changes:

sudo systemctl restart apache2

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:

  1. Create a DNS A record for a new subdomain (e.g., 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.

  2. Create directory /var/www/ssl and place the domain’s SSL cert and key files in it (e.g., and I’m assuming your 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 and use those.

  3. Enter chown -R ww-data:www-data /var/www/ssl so Apache owns the SSL files.

  4. Create file /etc/apache2/sites-available/ and give it the following contents (adjust as needed):

<VirtualHost *:443>
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	Alias /phpmyadmin /usr/share/phpmyadmin

	SSLEngine on
	SSLCertificateFile /var/www/ssl/
	SSLCertificateKeyFile /var/www/ssl/

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
  1. Enter chown -R ww-data:www-data /etc/apache2/sites-available/ so Apache owns the new conf file.

  2. Enter a2enmod ssl to enable SSL.

  3. Enter a2ensite to enable the subdomain in Apache.

  4. Enter systemctl restart apache2 to restart Apache.

That’s it! You should now be able to securely access the PhpMyAdmin panel by going to