sudo apt update&&sudo apt full-upgrade -yaria2c -j32 -s32 https://download.nextcloud.com/server/releases/latest.zip -o nextcloud.zipsudo apt install -y mariadb-server apache2 unzip smbclient imagemagick libmagickcore-6.q16-6-extra memcached libmemcached-tools php php-fpm php-imagick php-memcached php-apcu php-gd php-mysql php-curl php-mbstring php-intl php-gmp php-xml php-zip php-bz2 php-common php-cli php-bcmathsudo systemctl status mariadb # It should be active and running.sudo mysql_secure_installationsudo mariadb -u root -pCREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'password';CREATE DATABASE IF NOT EXISTS db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;SHOW DATABASES;GRANT ALL PRIVILEGES ON db.* TO 'nextcloud'@'localhost';FLUSH PRIVILEGES;quit;sudo cp nextcloud.zip /var/www/cd /var/wwwsudo unzip nextcloud.zipsudo chown -R www-data:www-data /var/www/nextcloudsudo phpenmod bcmath gmp imagick intlsudo a2dissite 000-default.confsudo a2enconf php8.2-fpmsudo a2enmod headers rewrite mpm_event http2 mime proxy proxy_fcgi setenvif alias dir env ssl proxy_http proxy_wstunnel# apache config<VirtualHost *:80>Protocols h2 h2c http/1.1ServerName 10.11.0.23DocumentRoot /var/www/nextcloud<IfModule mod_headers.c>Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"</IfModule><FilesMatch \.php$>SetHandler"proxy:unix:/var/run/php/php8.2-fpm.sock|fcgi://localhost"</FilesMatch><Directory /var/www/nextcloud/>Satisfy AnyRequire all grantedOptions FollowSymlinks MultiViewsAllowOverride All<IfModule mod_dav.c>Dav off</IfModule></Directory>ErrorLog /var/log/apache2/nextcloud-error.logCustomLog /var/log/apache2/nextcloud-access.log common</VirtualHost>sudo a2ensite nextcloud.confsudo vim /etc/memcached.conf # change "-m 64" to "-m 1024"sudo vim /etc/php/8.2/fpm/pool.d/www.conf# configpm.max_children = 80pm.start_servers = 20pm.min_spare_servers = 20pm.max_spare_servers = 60# uncomment these lines:env[HOSTNAME] = $HOSTNAMEenv[PATH] = /usr/local/bin:/usr/bin:/binenv[TMP] = /tmpenv[TMPDIR] = /tmpenv[TEMP] = /tmp### php configsudo vim /etc/php/8.2/fpm/php.ini # Andsudo vim /etc/php/8.2/apache2/php.inimemory_limit = 2048Mpost_max_size = 1024Mupload_max_filesize = 5Gmax_execution_time = 360date.timezone = Asia/Dhakapdo_mysql.default_socket=/run/mysqld/mysqld.sock# If cannot find the sock file the look into "sudo systemctl status mariadb". It will be in the status log.# down in opcache settings:opcache.enable=1opcache.memory_consumption=1024opcache.interned_strings_buffer=64opcache.max_accelerated_files=150000opcache.max_wasted_percentage=15opcache.revalidate_freq=60opcache.save_comments=1opcache.jit=1255opcache.jit_buffer_size=256Msudo systemctl restart apache2sudo systemctl restart memcachedsudo systemctl restart php8.2-fpmsudo mkdir /storage/nextcloud_datasudo chown -R www-data:www-data /storage/nextcloud_datasudo chmod 777 /storage/nextcloud_data# Go to nextcloud webpage and initialize.# nextcloud configsudo vim /var/www/nextcloud/config/config.php'memcache.local' =>'\OC\Memcache\APCu','memcache.distributed' =>'\OC\Memcache\Memcached','memcache.locking' =>'\OC\Memcache\Memcached','default_phone_region' =>'BD','maintenance_window_start' =>1, # The time here is in UTC. We are setting it to 7.'filesystem_check_changes' =>1,*Optional but highly recommended*Enable OCC -- nextcloud command line functionsudo vim /etc/php/8.2/mods-available/apcu.iniadd the following line at the bottom:apc.enable_cli=1save and exitin nextcloud go toadministration settings --> basic settings --> change from Ajax to Cron (recommended)
ifyou want to test if cron is workingsudo -u www-data php -f /var/www/nextcloud/cron.phpifyou see nothing it is working, if you get an error it is not workingsudo crontab -u www-data -e# Append the line in the configuration. This should run the command every 5 minutes. (Recommended by Nextcloud)*/5**** php -f /var/www/nextcloud/cron.php# To make it run the command every day at 13:00 Hrs.0 13 *** php -f /var/www/nextcloud/cron.php# You can verify if the cron job has been added and scheduled by executing:sudo crontab -u www-data -l# Install "Preview Generator" and "Memories" from Nextcloud app store and setup memories app from the dashboard.sudo -u www-data php /var/www/nextcloud/occ memories:index