[solved][NextCloudPi]Access Next Cloud from Hostname.com/NextCloud

I used the nextcloudpi image for the raspberrypi from ownyourownbits

Currently, when I go to my hostname.com (obvious not my real hostname) it goes directly to owncloud login
But I want to use my homepage for a website as well. How can I access it from a specified directory or page like hostname.com/NextCloud?

Check the directory structure: it should be something like /var/www/html/
Most likely it is already in a /nextcloud folder there with a rewrite rule in Apache (.htaccess) or Nginx config. Then you just need to change that.
If it is directly in /var/www/html/ I guess the best would be to reinstall it in a subdirectory and remove the current files.

But this is based on a typical ubuntu install, never used the Rasberry image you mentioned and thus it might be totally different there.

1 Like

It’s in the a folder call nextcloud (/vae/www/nextcloud/) I am new to linux and webhosting. It automatically redirects to NextCloud as soon as I go to my domain. So what should I change?

In /var/www/html/ there is just one index file.

I have no idea what to edit. The .htacess file… I don’t what to change

What you have to configure is Apache Virtual Hosts.

In NextCloudPi, the virtual host for Nextcloud is in /etc/apache2/sites-available/nextcloud.conf. In that file you can set the Root for the virtual host that finds its files in /var/www/nextcloud.

You can see that in port 443 the document root is /var/www/nextcloud. Change it to /var/www and then you can have your other website in /var/www/mywebsite and access nextcloud as https://ip/nextcloud and your site as https://ip/mysite

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    DocumentRoot /var/www/nextcloud
ServerName XXX
    CustomLog /var/www/nextcloud/data/access.log combined
    ErrorLog /var/www/nextcloud/data/error.log
    SSLEngine on
    SSLCertificateFile /XXX
    SSLCertificateKeyFile /XXX
  </VirtualHost>
  <Directory /var/www/nextcloud/>
    Options +FollowSymlinks
    AllowOverride All
    <IfModule mod_dav.c>
      Dav off
    </IfModule>
    LimitRequestBody 0
    SSLRenegBufferSize 10486000
  </Directory>
</IfModule>

do i have to change nextcloud folder in /var/www/nextcloud to alter the subdirectory it’s for example if I wanted it cloud would I have to rename nextcloud, cloud?

you don’t have to change that folder, but you can. If you want to access https://ip/cloud you can rename /var/www/nextcloud to /var/www/cloud.

I don’t recommend it because it would mess up with NextCloudPi, which assumes the first path.

is there a way to access it via sub-directory http://hostname/cloud without changing document root folder name?

solved. First mod_alias must be loaded. Go to /etc/apache2/mods-enabled and make a file called alias.load put this one line in there:

LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so

next change document root as follows. Go to /etc/apache2/sites-available/nextcloud.conf and change document root from /var/www/nextcloud to

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    DocumentRoot /var/www/
ServerName XXX
    CustomLog /var/www/nextcloud/data/access.log combined
    ErrorLog /var/www/nextcloud/data/error.log
    SSLEngine on
    SSLCertificateFile /XXX
    SSLCertificateKeyFile /XXX
  </VirtualHost>
   Alias /cloud /var/www/nextcloud/
  <Directory /var/www/nextcloud/>
    Options +FollowSymlinks
    AllowOverride All
    <IfModule mod_dav.c>
      Dav off
    </IfModule>
    LimitRequestBody 0
    SSLRenegBufferSize 10486000
  </Directory>
</IfModule>

Restart apache using service apache2 restart in terminal

Now you can access nextcloud from https://hostname/cloud it will also be accessible from https://hostname/nextcloud , which isn’t ideal but works ok for my configuration

cool, good job