您现在的位置是:首页 >其他 >Nextcloud集成Onlyoffice实现协同办公。网站首页其他
Nextcloud集成Onlyoffice实现协同办公。
Nextcloud 安装
LAMP(Linux+Apache+MySQL+PHP)方式。局域网单机模式。
安装环境:
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)
注:我安装时防火墙处于关闭状态
关闭防火墙:sudo ufw disable
安装依赖:
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
配置数据库
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;
安装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
换个地方
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
测试Apache能否解析PHP
sudo vi /var/www/html/phpinfo.php
文件中写:<?php echo phpinfo();?>
浏览器访问:http://your ip/phpinfo.php,出现PHP Version网页
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>
执行
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
重启apache2
sudo systemctl restart apache2
查看一下状态:
systemctl status apache2.service
修改一下数据存储目录
cd /var/www/
sudo mkdir nextcloud-data
sudo chown www-data:www-data nextcloud-data/
也可以
sudo chown -R www-data:root nextcloud-data
这样sudo -i 切换到root用户可以访问nextcloud-data文件夹。
配置Nextcloud
登陆:http://ip/nextcloud
根据提示配置就行。
登陆后的文件管理页面:
安装onlyoffice
安装依赖
apt install nginx nginx-extras postgresql redis-server rabbitmq-server gnupg2 -y
启动RabbitMQ postgresql Redis service
systemctl start rabbitmq-server
systemctl start redis-server
systemctl start postgresql
配置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;"
注意:用户名必须是ONLYOFFICE,密码任意指定。
添加GPG密钥:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
添加ONLYOFFICE Docs软件源仓库
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
安装onlyoffice-documentserver
sudo apt install onlyoffice-documentserver
sudo chown -R www-data:www-data onlyoffice
修改nginx的端口
系统内还有apache,为了避免端口冲突需要修改nginx的端口。
ip:8090/welcome/
sudo vim /etc/nginx/sites–available/default
把80改成81
修改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;
}
重启一下nginx:
sudo systemctl reload nginx
或:
sudo systemctl restart nginx
登陆看一看,欢迎页面。
ip::8090/welcome/
配置Nextcloud集成onlyoffice
点击右上角的用户图标,然后点击Apps,再点击Office&text,找到ONLYOFFICE,再点击。
点击Administration settings,点击左侧栏ONLYOFFICE
Secret key (leave blank to disable)这里的输入,依据onlyoffice 欢迎页面“Starting from version 7.2, JWT is enabled by default.”这段来找。
在Files可以进行文件管理和操作。下图是打开文件的情形:
问题
PHP 内存限制低于建议值 512MB。
cd /etc/php/8.1/apache2
sudo vim php.ini
找到memory_limit = 128M,将128M修改是512M
memory_limit = 512M
重启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
修改:
opcache.interned_strings_buffer=16
重启apache2
systemctl restart apache2.service
配置redis
安装
sudo apt install redis-server php-redis php8.1-fpm
sudo systemctl enable redis-server
检查扩展是否启用(redis):php --ri redis
如果未启用,请运行以下命令:
sudo phpenmod redis
如果 redis 扩展仍未启用,您可能还需要重新加载 Apache。
sudo systemctl reload apache2
看一下版本:
redis-server -v
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=a3fdef44459b3ad6
支持systemctl:
sudo vim /etc/redis/redis.conf
supervised no
修改为:
supervised systemd
上面的步骤是为了可以对redis使用systemctl命令
sudo systemctl restart redis
编辑 nextCloud 配置文件。
sudo vim /var/www/nextcloud/config/config.php
'memcache.distributed' => 'OCMemcacheRedis',
'memcache.local' => 'OCMemcacheRedis',
'memcache.locking' => 'OCMemcacheRedis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),
然后重新启动 Apache 和 PHP8.1-FPM。
sudo systemctl restart apache2 php8.1-fpm
现在再次转到 NextCloud 设置->概览页面并刷新网页,关于内存缓存的警告应该消失了。
重置管理员密码:
sudo -u www-data php /var/www/nextcloud/occ user:resetpassword username
还有其他一些您可能会觉得有用的命令。列出可用命令:
sudo -u www-data php /var/www/nextcloud/occ
修改数据目录:(这里有点问题? .ocdata 权限是644,好像是这个权限的问题)
sudo vim /var/www/nextcloud/config/config.php
'datadirectory' => '/var/www/nextcloud-data',
让www-data可以写入:
sudo chown -R www-data:www-data /var/www/nextcloud-data
sudo systemctl restart apache2
打开网页时提示:需要“.ocdata”,索性把data目录下的文件全部复制到nextcloud-data文件夹下。
.ocdata 权限是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/
参考:
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