vimsee said
Hi!
Now, I also want to add a wordpress site as well, prefeably under www.mydomain.com (which is already used for my nextcloud server) and then change my nextcloud installation to go under www.nextcloud.mydomain.com.
I can setup a new database and install it, but I`m afraid it will mess with my apache configuration as well as the SSL certificate.
Hello there, thanks for stopping by! This is a fairly easy use case; the hardest part will be moving your Nextcloud server's URL.
First, you'll want to set up another A record in your DNS pointing to the same IP address. (I'd recommend just using nextcloud.mydomain.com, but if you want www.nextcloud.mydomain.com, you can try creating an A record of "www.nextcloud".)
You can separate out your subdomain traffic using Apache by setting up virtual hosts. These are the files located at /etc/apache2/sites-available (and symlinked to /etc/apache2/sites-enabled after you run the a2ensite command.)
If you're using the default vhost, you'll want to make a copy of /etc/apache2/sites-available/000-default.conf to a location like /etc/apache2/sites-available/nextcloud.conf, and uncomment the ServerName line. Set the ServerName to nextcloud.mydomain.com, and make sure the DocumentRoot points to the location where your Nextcloud files are.
After you save that file, you'll want to run "a2ensite nextcloud" if you called the file nextcloud.conf, and then run Certbot again to make Let's Encrypt set up TLS for that site. Next is the tricky part: if you go to nextcloud.mydomain.com, you'll probably see a Nextcloud error. You'll need to edit /var/www/html/config/config.php (or wherever your Nextcloud config.php is located) and change the domain from www.mydomain.com to nextcloud.mydomain.com. After doing that, Nextcloud should let you access itself from the new URL.
Finally, you'll want to create a new directory in /var/www, maybe /var/www/wordpress, and change the DocumentRoot in your old /etc/apache2/sites-available file to point to that directory. (Alternatively, you could create another new vhost file called "wordpress.conf", set the ServerName to www.mydomain.com, set your DocumentRoot in that file, and run "a2ensite wordpress" to enable the vhost.) If at any point you don't have HTTPS (or you don't have it set up correctly), just run Certbot again and try to get it to apply Let's Encrypt to your configuration.
Let me know if this helps & if you have any questions/issues!