Pre-installation configuration question(s) - Self hosted

I’d like to try a self hosted instance of Invoice Ninja following some adverse changes to my current invoice platform.
I run a server (Ubuntu 18.04) that currently only runs an instance of Nextcloud and pi-hole.
I have Nextcloud set up under but ideally I’d like to change that to so that I can also have
The next cloud files are installed in /var/www/html.
Should I originally have installed them in /var/www/html/nextcloud so that I can now create /var/www/html/invoiceninja?
I’d really rather not start all over. If this is possible to do can someone point me to some good information on it as I’m not even sure what to search for.


What folder the files are in doesn’t matter, as long as Apache knows where to look for what site. /var/www/html is simply the default folder that Apache uses, and is fine for most cases. I keep my own in /var/www/ninja/.

What you’re looking to do is create a subdomain. To do that, you’ll have to update the DNS entries with your registrar first. Then you’ll need to configure the vhosts in apache for each site. So you’ll have a config file for,, and, all of which will need entries in the DNS with your registrar. The config files will need to have the ServerName variable set, because when a request comes in, that’s what will determine which set of pages gets served. But as long as DocumentRoot is pointed to wherever the correct files are, there’s no need to start over. might explain this a bit better than I can (as subdomains aren’t really my area).

Thanks for your reply,

I think I’ve made some progress.
I have set up a subdomain forward with my registrar and if I ping I see my public IP address returned - so that appears to be working.
I have created /var/www/newthing and placed a basic html file in it but going to doesn’t work.
My virtual host file, in /etc/apache2/sites-available reads (comments removed);

<VirtualHost *:80>        ServerName
        DocumentRoot /var/www/newthing
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

The contents of ports.conf is;

`# If you just change the port or add more ports here, you will likely also# have to change the VirtualHost statement in


Listen 80
<IfModule ssl_module>
Listen 443
<IfModule mod_gnutls.c>
Listen 443

When I try to access it’s getting redirected to
From memory, when I set up nextcloud this was also something I set up for security measures. But I can’t really remember anything about it - I think it’s a product of letsencrypt. I’ve tried changing my virtual hosts file for newthing to <VirtualHost *:443> but the result has been the same.

My sites-available directory contains: (contains the virtual host info for the nextcloud install)

My sites-enabled directory contains:

Hoping someone can help.


I was a bit off when I mentioned needing separate conf files for each site. You should be able to put multiple VirtualHost entries in the same conf that you were already using.

So for example, you’d be doing something like the following (adapted from

<VirtualHost *:80>
    DocumentRoot "/var/www/html/nextcloud"

    # Rest of the stuff here

<VirtualHost *:80>
    DocumentRoot "/path/to/invoiceninja/public"

    # Rest of the stuff here

The top entry will be the “primary”, meaning that without anything else specified (such as just typing in “”), that’s the set of pages it will serve. The ServerName entry there is basically just a fallback in case no other lookup works. But normally, unless specifically requested, it will serve what’s in the /nextcloud folder by default, so it should work with either “” or “”.

However, if you use “”, it will see that as something specifically defined, and lookup whatever is in the specified folder (always point to ninja/public, as you don’t want people being able to see/read your .env file).

And be sure to restart apache after any changes so they take effect.

Thanks again,
I’ll have another look at it tomorrow.


I’m all good now - thanks for the replies.
I think the crux of the matter was that I had to add my new subdomain to my existing SSL certificate.