Tag: nextcloud

  • Reset nextcloud admin password (snap install)

    Reset nextcloud admin password (snap install)

    To reset the admin password of a nextcloud installed using the snap package, run

    sudo nextcloud.occ user:resetpassword USER_NAME_HERE
    

    It will ask for the new password, once you enter the password and confirmed it your nextcloud admin password will be changed.

  • Enable/Disable Nextcloud Maintenance Mode

    Enable/Disable Nextcloud Maintenance Mode

    Maintenance mode is useful when you are making changes to your nextcloud installation like a software upgrade.

    To enable maintenance mode, run the command

    php7.3 occ maintenance:mode --on
    

    To disable maintenance mode, run

    php7.3 occ maintenance:mode --off
    

    Example

    www-data@mail:/www/nextcloud$ php occ maintenance:mode --off
    Maintenance mode disabled
    www-data@mail:/www/nextcloud$ 
    

    See Nextcloud

  • NextCloud APCu not available for local cache

    NextCloud APCu not available for local cache

    When trying to upgrade nextcloud, I get the following error

    www-data@mail:/www/nextcloud$ php7.3 occ upgrade
    An unhandled exception has been thrown:
    OC\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)
    www-data@mail:/www/nextcloud$ 
    

    To fix this, you need to install APC cache.

    apt install php7.3-apcu
    

    For CLI, you need to edit PHP configuration file

    vi /etc/php/7.2/cli/php.ini
    

    at the end of the file, add

    apc.enable_cli = 1
    

    You can also enable apc for the current command with option

    php7.3 -d apc.enable_cli=1 occ upgrade
    
  • Reset NextCloud user password from command line

    Reset NextCloud user password from command line

    You can use lost password link in login page to reset password. If you don’t have a valid email set or mail server not working, you can reset the password using SSH.

    NextCloud users are stored in table oc_users. If you don’t know the user name, you can use following SQL command to see all available users.

    select * from oc_users;
    

    To reset password for a user, login to SSH, go to DocumentRoot for the web site. This is the folder where you uploaded NextCloud files. Then run

    php occ user:resetpassword USERNAME_HERE
    

    On following screenshot, i reset password for user “admin”.

    nextcloud password reset command line

    It will ask you to enter password 2 times.

    See NextCloud

  • Install Preview Generator in Nextcloud

    Install Preview Generator in Nextcloud

    To enable preview for files in nextcloud, you need to install “Preview Generator” from next cloud app store

    https://apps.nextcloud.com/apps/previewgenerator

    To install login to nextcloud as admin. From right drop down menu, click + Apps link.

    Nextcloud apps

    Once on Apps page, you can use the search button on right side to search for “Preview Generator” and install it.

    You need to install some additional software, on ubuntu/debian install it with

    sudo apt install libreoffice ffmpeg imagemagick ghostscript
    

    Now edit config/config.php file of your nextcloud installation, add following code

    'enable_previews' => true,
    'preview_libreoffice_path' => '/usr/bin/libreoffice',
    'enabledPreviewProviders' =>
     array (
        0 => 'OC\\Preview\\TXT',
        1 => 'OC\\Preview\\MarkDown',
        2 => 'OC\\Preview\\OpenDocument',
        3 => 'OC\\Preview\\PDF',
        4 => 'OC\\Preview\\MSOffice2003',
        5 => 'OC\\Preview\\MSOfficeDoc',
        6 => 'OC\\Preview\\PDF',
        7 => 'OC\\Preview\\Image',
        8 => 'OC\\Preview\\Photoshop',
        9 => 'OC\\Preview\\TIFF',
       10 => 'OC\\Preview\\SVG',
       11 => 'OC\\Preview\\Font',
       12 => 'OC\\Preview\\MP3',
       13 => 'OC\\Preview\\Movie',
       14 => 'OC\\Preview\\MKV',
       15 => 'OC\\Preview\\MP4',
       16 => 'OC\\Preview\\AVI',
     ),
    

    Generate Preview for existing files

    Let’s generate thumbnail for existing files, for this, I enabled shell access for www-data so preview files have proper file ownership (not owned by root).

    chsh --shell /bin/bash www-data
    

    Now change to www-data user

    su - www-data
    

    Now run

    /usr/bin/php /var/www/nextcloud/occ preview:generate-all -vvv
    

    nextcloud

    Autogenerate Previews for new files

    set a cronjob as user www-data

    crontab -e -u www-data
    
    */5 * * * * /usr/bin/php /var/www/nextcloud/occ preview:pre-generate > /dev/null 2>&1
    

    See Nextcloud

  • Enable SEO url in nextcloud

    To enable SEO url in next cloud, first make sure your web server have mod_rewrite module enabled.

    Edit config.php file

    vi config/config.php
    

    add following

    'overwrite.cli.url' => 'https://yourdomain.com/',
    'htaccess.RewriteBase' => '/',
    

    overwrite.cli.url may already there, in that case, don’t add it again.

    Now run

    sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
    

    See NextCloud