Error 404 while trying to setup a virtual host for my nextcloud on apache

Nextcloud version (eg, 20.0.5): 22
Operating system and version (eg, Ubuntu 20.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): 2.4.52
PHP version (eg, 7.4): 8.1

The issue you are facing:

Hello,

i’m trying to setup a virtual host for my self hosted nextcloud instance on my debian 11 home server.

But now when i try to reach the nextcloud interface (www.nextcloud.local) it’s not working (not found adress).

And if i type my old adress like http://server-ip/nextcloud, i got an error 404.

my nextcloud folder is located under var/www/.

here is my nextcloud.conf settings under etc/apache2/sites-available/

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost

        ServerName nextcloud.local
        ServerAlias www.nextcloud.local
        DocumentRoot /var/www/nextcloud

        <Directory "/var/www/nextcloud">
                Options FollowSymLinks MultiViews
                AllowOverride All
        </Directory>

        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

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

        <IfModule mpm_itk_module>
                AssignUserId nextcloud nextcloud
        </IfModule>
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

thanks for your help.

any help ?

you may need to let all your clients know where they can find nextcloud.local by putting it in there HOSTS file or something.

also you should probably use http://server-ip without the /nextcloud as apache is already looking in /var/www/nextcloud/ and /var/www/nextcloud/nextcloud does not exsists theres a 404