Nextcloud integrates Onlyoffice to realize collaborative office.

Nextcloud installation

LAMP (Linux+Apache+MySQL+PHP) method. LAN stand-alone mode.

Installation Environment:

OS:ubuntu 22.04
Nextcloud:26
Apache:2.4.52
mysql:Server version: 8.0.33-0ubuntu0.22.04.1 (Ubuntu)
php:PHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22: 56:18) (NTS)

Note: The firewall was turned off when I installed it.
Turn off the firewall: sudo ufw disable

Installation dependencies:

sudo apt install apache2 libapache2-mod-php php-gd php-mysql
php-curl php-mbstring php-intl php-gmp php-bcmath php-xml php-imagick php-zip mysql-server

configuration database

sudo mysql -u root -p

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 'root'@'localhost';
FLUSH PRIVILEGES;

Install Nextcloud

sudo wget https://download.nextcloud.com/server/releases/latest-26.tar.bz2
sudo wget https://download.nextcloud.com/server/releases/latest-26.tar.bz2.md5
sudo wget https://download.nextcloud.com/server/releases/latest-26.tar.bz2.sha256

Verify the MD5 or SHA256 sum:

md5sum -c latest-26.tar.bz2.md5 < latest-26.tar.bz2
sha256sum -c latest-26.tar.bz2.sha256 < latest-26.tar.bz2

change place

tar -xvzf latest-26.tar.bz2
sudo cp -r nextcloud /var/www/

Finally, change the ownership of your Nextcloud directories to your HTTP user:

sudo chown -R www-data:www-data /var/www/nextcloud

Test whether Apache can parse PHP

sudo vi /var/www/html/phpinfo.php

Write in the file: <?php echo phpinfo();?>
Browser access: http://your ip/phpinfo.php, the PHP Version web page appears

Apache Web server configuration

sudo touch /etc/apache2/sites-available/nextcloud.conf
sudo chown  www-data:www-data /etc/apache2/sites-available/nextcloud.conf
sudo vim  /etc/apache2/sites-available/nextcloud.conf
 Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

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

implement

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

restart apache2

sudo systemctl restart  apache2

Check the status:

systemctl status apache2.service

Modify the data storage directory

cd /var/www/
sudo mkdir nextcloud-data
sudo chown www-data:www-data nextcloud-data/

can also

sudo chown -R www-data:root nextcloud-data

In this way, sudo -i switches to the root user to access the nextcloud-data folder.

Configure Nextcloud

Login: http://ip/nextcloud
Follow the prompts to configure.
insert image description here
insert image description here

File management page after login:
insert image description here

install onlyoffice

install dependencies

apt install nginx nginx-extras postgresql redis-server rabbitmq-server gnupg2 -y

Start the RabbitMQ postgresql Redis service

systemctl start rabbitmq-server
systemctl start redis-server
systemctl start postgresql

configure postgresql

sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

Note: The user name must be ONLYOFFICE, and the password can be specified arbitrarily.

Add GPG key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5

Add ONLYOFFICE Docs software source repository

echo "deb https://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
sudo apt update
sudo apt-get install ttf-mscorefonts-installer

Install onlyoffice-documentserver

sudo apt install  onlyoffice-documentserver

sudo chown -R www-data:www-data onlyoffice

Modify the port of nginx

There is also apache in the system. In order to avoid port conflicts, the port of nginx needs to be modified.
ip:8090/welcome/

sudo vim /etc/nginx/sites–available/default

Change 80 to 81
insert image description here
to modify the port number of onlyoffice

sudo more /etc/onlyoffice/documentserver/nginx/ds.conf

include /etc/nginx/includes/http-common.conf;
server {
    
    
  listen 0.0.0.0:8090;
  listen [::]:8090 default_server;
  server_tokens off;
  
  set $secure_link_secret 4xpWTVkw5RZcrYPR6YHv;
  include /etc/nginx/includes/ds-*.conf;
}

Restart nginx:

sudo systemctl reload nginx
或:
sudo systemctl restart nginx

Log in and take a look at the welcome page.

ip::8090/welcome/
insert image description here

Configure Nextcloud to integrate onlyoffice

insert image description here
Click the user icon in the upper right corner, then click Apps, then click Office&text, find ONLYOFFICE, and click again.
insert image description here
Click Administration settings, click ONLYOFFICE insert image description here
Secret key (leave blank to disable) input in the left column, and find it according to the onlyoffice welcome page "Starting from version 7.2, JWT is enabled by default."

File management and operations can be performed in Files. The following figure shows the situation of opening a file:
insert image description here

question

The PHP memory limit is below the recommended value of 512MB.

cd /etc/php/8.1/apache2
sudo vim php.ini 

Find memory_limit = 128M, modify 128M to 512M

memory_limit = 512M

restart apache2

systemctl start  apache2.service
systemctl status apache2.service

The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached, it is recommended to apply opcache.interned_strings_buffer to your PHP configuration with a value higher than `8’

cd /etc/php/8.1/apache2
sudo vim php.ini 

Revise:

opcache.interned_strings_buffer=16

restart apache2

 systemctl restart  apache2.service

configure redis

Install

sudo apt install redis-server php-redis php8.1-fpm

sudo systemctl enable redis-server

Check if the extension is enabled (redis): php --ri redis

insert image description here
If it is not enabled, run the following command:

sudo phpenmod redis

You may also need to reload Apache if the redis extension is still not enabled.

sudo systemctl reload apache2

Take a look at the version:

redis-server -v
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=a3fdef44459b3ad6

Support systemctl:

sudo vim /etc/redis/redis.conf
supervised no

change into:

supervised systemd

The above steps are to use the systemctl command for redis

sudo systemctl restart redis

Edit the nextCloud configuration file.

sudo vim /var/www/nextcloud/config/config.php
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
     'host' => 'localhost',
     'port' => 6379,
     ),

insert image description here
Then restart Apache and PHP8.1-FPM.

sudo systemctl restart apache2 php8.1-fpm

Now go to NextCloud Settings -> Overview page again and refresh the page, the warning about memcached should disappear.

To reset the admin password:

sudo -u www-data php /var/www/nextcloud/occ user:resetpassword username

There are a few other commands that you might find useful. List available commands:

sudo -u www-data php /var/www/nextcloud/occ

Modify the data directory: (There is a problem here? The .ocdata permission is 644, it seems to be a problem with this permission)

sudo vim  /var/www/nextcloud/config/config.php
'datadirectory' => '/var/www/nextcloud-data',

Make www-data writable:

sudo chown -R www-data:www-data /var/www/nextcloud-data
sudo systemctl restart apache2

When opening the webpage, it prompts: ".ocdata" is needed, simply copy all the files in the data directory to the nextcloud-data folder.
.ocdata permission is 644

cd /var/www/nextcloud
sudo cp -r ./data ../
cd /var/www
sudo chown xxx:xxx -R data
cd data
sudo cp -r ./ ../nextcloud-data/
cd /var/www/nextcloud
sudo rm -r ./data/

reference:

https://afterlogic.com/docs/aurora/frequently-asked-questions/configuring-onlyoffice-docs-with-non-standard-port
https://www.louishe.com/2021/10/28/doc-11120.html
https://www.linuxbabe.com/cloud-storage/upgrade-nextcloud-command-line-gui

sudo -u www-data php /var/www/nextcloud/occ files:scan --all

Guess you like

Origin blog.csdn.net/philosophyatmath/article/details/130594037