Installing Nextcloud and Wordpress in the same directory

Hello I’m running a wordpress site on my own server with let’s encrypt enabled.
I would like to have nextcloud showing like this: https://www.mysite.com/nextcloud.
Worpress is installed in the /var/www/html/wordpress directory. Everything works fine. I then installed Nextcloud in the same location /var/www/html/nextcloud.
Once I enabled my nextcloud.conf i get an SSL error.

this is my wordpress-le-ssl.conf file

<IfModule mod_ssl.c>

<VirtualHost *:443>
ServerAdmin dbaldoni@gmail.com
ServerName terraveler.com
ServerAlias www.terraveler.com
DocumentRoot /var/www/html/terraveler
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/terraveler.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/terraveler.com/privkey.pem

this is my nextcloud.conf file

<IfModule mod_ssl.c>
 ServerAdmin xxxi@xxx.xxx
 ServerName www.terraveler.com
 DocumentRoot /var/www/html

 <Directory /var/www/html/>
   Options +FollowSymlinks
   AllowOverride All

  <IfModule mod_dav.c>
    Dav off
  </IfModule>

   SetEnv HOME /var/www/html/
   SetEnv HTTP_HOME /var/www/html/
 </Directory>

 <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15768000; preload"
 </IfModule>

 SSLEngine on
 SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
 SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Where do I go wrong?

Thank you

Wouldn’t it be good to let us know what exact SSL error is being displayed?!

Administrators are encouraged to install Nextcloud on a dedicated domain such as cloud.domain.tld instead of domain.tld to gain all the benefits offered by the Same-Origin-Policy.

https://docs.nextcloud.com/server/15/admin_manual/installation/harden_server.html?highlight=dedicated%20domain#use-a-dedicated-domain-for-nextcloud

Along with what Sanook said, I believe it is best to use subdomains.

I have done what you describe using a subdomain for the nextcloud portion without issues with my SSL cert, if I understand your problem correctly.

e.g. I have wordpress installed for the root folder of mysite.com and then a separate subdomain at cloud.mysite.com with its own root folder on the server and it works.

Mee too, but then the federation URL is @cloud.mysite.com and the social URL (Mastodon) is @user@cloud.mysite.com.

I would like to change it to @mysite.com and @user@mysite.com.

I actually did it and it works. Problem solved. Thank you all.