VMware

Make Nextcloud fast! Full tutorial and server setup!



Nextcloud is a great system for setting up your personal cloud and sharing with friends. It can be frustrating when it is slow. Let’s get nextcloud entirely setup and optimized for performance on your server!

** PHP 8.3 is out. Nextcloud currently will NOT run on php8.3. Many required php packages for php8.3 are not out yet, such as intl, mysql, curl, and others**

** This guide has been updated to specify installing php 8.2 packages, be sure you are running php8.2!**

**Nextcloud 28 is out, it also wants you to install bz2 php extension**
**sudo apt-get install php8.2-bz2**

*Server setup*
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install apache2 php8.2-fpm

sudo nano /etc/apache2/sites-available/nextcloud.conf

*paste in the code from here:*

sudo a2enconf php8.2-fpm

sudo a2ensite nextcloud.conf

sudo apt-get install imagemagick php8.2-imagick memcached libmemcached-tools php8.2-memcached php8.2-apcu mariadb-server php8.2-gd php8.2-mysql php8.2-curl php8.2-mbstring php8.2-intl php8.2-gmp php8.2-bcmath php8.2-xml php8.2-zip unzip smbclient

sudo a2enmod headers rewrite mpm_event http2 mime proxy proxy_fcgi setenvif alias dir env ssl proxy_http proxy_wstunnel

sudo a2dismod mpm_prefork

sudo nano /etc/memcached.conf
change 64 to 1024

*save and exit*

sudo nano /etc/php/8.2/fpm/pool.d/www.conf
max_children = 80
start_servers = 20
min_spare_servers = 20
max_spare_servers = 60

*uncomment these lines:*
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

*save and exit*

sudo nano /etc/php/8.2/fpm/php.ini

memory_limit = 1024M
post_max_size = 512M
upload_max_filesize = 1024M

*down in opcache settings:*
opcache.enable=1
opcache.memory_consumption=1024
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=150000
opcache.max_wasted_percentage=15
opcache.revalidate_freq=60
opcache.save_comments=1
opcache.jit=1255
opcache.jit_buffer_size=256M

*save and exit*

*setup MariaDB*
sudo mysql

CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’;
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘username’@’localhost’;
FLUSH PRIVILEGES;

quit;

cd /var/www

sudo wget
sudo unzip nextcloud-27.1.4.zip
sudo chown -R www-data:www-data /var/www/nextcloud

sudo systemctl restart apache2
sudo systemctl restart memcached
sudo systemctl restart php8.2-fpm

*open website and continue nextcloud isntallation on new website*

sudo nano /var/www/nextcloud/config/config.php

*grab the code to add from here:*

save and exit

sudo systemctl restart apache2 just in case.

*Your nextcloud should now be running optimally!*

**Optional but highly recommended**
Enable OCC — nextcloud command line function

sudo nano /etc/php/8.2/mods-available/apcu.ini

*add the following line at the bottom:*
apc.enable_cli=1

save and exit

in nextcloud go to
administration settings — basic settings — change from Ajax to Cron (recommended)

if you want to test if cron is working
sudo -u www-data php -f /var/www/nextcloud/cron.php

if you see nothing it is working, if you get an error it is not working

[ad_2]

source

Related Articles

30 Comments

  1. PHP 8.3 is out, but it currently will not work. I updated video description. Ensure you are getting and using php8.2 as well as only using php8.2 extensions (php8.2-curl, etc).

  2. Hello my friend! All good?

    I'm using nextcloud with nginx and php8.2. installed on a Virtual Box. The files (.pdf, .jpeg…) do not open in the browser, only via download. Another problem, when I drag and drop files, the upload doesn't happen.

    Thank you for sharing your knowledge.

  3. thank you so much for your brilliant video! I have one small problem however – even when activating chron just like mentioned in the description it just does not seem to runn properly – I'm getting the error that no jobs have been run for x amount of hours – do you have any ideas on how to fix this? 🙂

  4. Thank you so much for this tutorial! Really easy to follow and worked like a charm!

    However I do have one quite big problem – when uploading files my nextcloud-install keeps going into maintenance mode – do you have any idea on what to do about this?
    Here are my arguably pretty low-end specs:
    Intel(R) Celeron(R) CPU N3010 @ 1.04GHz (2 cores)
    4GB Ram
    16GB SSD

    any help would be really really appreciated!

  5. 'memcache.local' => 'OCMemcacheAPCu',
    'memcache.distributed' => 'OCMemcacheMemcached',
    'memached.locking' => 'OCMemcache Memcached',

    for anyone looking for the last memcache snippets – here you go 🙂 –

  6. Hi. I Followed yous instructions and everithing work very well, but after 2 days i was no longer able to access my files. I found the following alert in the configurations warnings. Some indexes are missing from the database due to the fact that aded on large tables, it take some time they were not added automatically. Running "occ db:add-missing-indices", missing indexes can be added manualy while nextcloud is still running. When i try to execute the command, the following error message apears: An unhandled exception has been thrown:
    OCPHintException: [0]: Memcache OCMemcacheAPCu not available for local cache (Is the matching PHP module installed and enabled?). Could you please help me. Thank you very much.

  7. the line for the php8.2 gets the following errors.
    E: Unable to locate package php8.2-imagick

    E: Couldn't find any package by glob 'php8.2-imagick'
    E: Couldn't find any package by regex 'php8.2-imagick'
    E: Unable to locate package php8.2-memcached
    E: Couldn't find any package by glob 'php8.2-memcached'
    E: Couldn't find any package by regex 'php8.2-memcached'
    Any ideas?.

  8. How about a Truenas Scale Nextcloud APP version setup? I have run into issues with larger than 10GB file uploads having to mess with chunk sizes etc etc would love to see a video on that. Thanks

  9. Quick heads up! (Error 404 on 24:30?)

    If when you follow everything he said in this video, you get an 404 error with "file not found" roughly at 24:30 into the video, it means you just need to go open "/etc/apache2/sites-available/000-default.conf" and set the root directory to /etc/www/ instead of /etc/www/html.

    To do this, follow this:
    ================================
    sudo nano /etc/apache2/sites-available/000-default.conf
    > Change
    >>>DocumentRoot /etc/www/html
    > To
    >>>DocumentRoot /etc/www/
    >Save and Exit

    sudo systemctl restart apache2

    sudo systemctl restart memcached

    sudo systemctl restart php8.2-fpm
    ================================
    Now you can access your nextcloud with = http://<your hostname/IP>/nextcloud/index.php

    Have fun!

  10. when run "sudo add-apt-repository ppa:ondrej/php"
    i got this error, how to fix this ??

    gpg: keybox '/tmp/tmp_7v9_1s8/pubring.gpg' created

    gpg: keyserver receive failed: Permission denied

  11. Thank you for making a rosetta stone video that translates for a newbie like me the Egyptian hieroglyphs the official Nextcloud installation documentation is written in. How will your installation instructions change if my goal is to keep my Nextcloud/Unbuntu Server v22.04.3 home server fenced in within my home network? I don't really have a need to access my Nextcloud using my cellphone when I find myself at a McDonalds. But while at home I do need my cellphone to interface with my Nextcloud to sync data via wifi. For this scenario does the <VirtualHost *:80> text require it be changed to <VirtualHost *:xxxx> (xxxx = whatever port number)? Or do I leave the <VirtualHost *:80> text as is? I hope this is less complicated to configure compared to having the capability to access my Nextcloud while I am at a McDonalds.

  12. I followed your guide but cron doesnt run automatic, it works when i run the command you listed.
    And there are missconfigured /.well-known/caldav and .well-known/carddav.

    Any tips on how to solve these?

  13. Great tutorial. One that actually works 👍
    After deployment there is som errors in nextcloud and and one is about secure connection to nextcloud. I use Cloudflare tunnel to connect to nextcloud from outside. Do you know what i can do to make it connect via https?

  14. Just wanted to say thanks for your very helpful video. I kept trying to do this in docker and never got it to run right. Your videos and the show notes you provide are great. Look forward to more of your content. Ill be plugging your channel on Reddit.

  15. thank you for the guide
    for me adding to the config.php file

    'memcache.local' => 'OCMemcacheAPCu',
    'memcache.distributed' => 'OCMemcacheMemcached',
    'memcache.locking' => 'OCMemcacheMemcached',

    results in internal error.

  16. hey im not able to get the occ command to run, i need it for scanning the files uploaded through scp on my windows machine, any idea what might be wrong ? rest everything is working fine thanks! I tried the commands in the description it didnt work too, im getting a sudo: nextcloud.occ: command not found

  17. the first thing I do when installing nextcloud is looking at the security & setup warnings as there are often showing missing configs or false settings. also setting up occ is necessary to configure nextcloud down the road. in addition, setting up background job/cron job is another issue that needs to get fixed right at the beginning.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button