V1在这里:https://blog.csdn.net/philosophyatmath/article/details/130594037。V2没有继续使用onlyoffice而是使用nextcloud office
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
配置数据库
创建nextcloud用户,nextcloud数据库。
sudo mysql -u root -p
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'Nextcloud@123';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
安装Nextcloud
sudo wget https://download.nextcloud.com/server/releases/latest-27.tar.bz2
sudo wget https://download.nextcloud.com/server/releases/latest-27.tar.bz2.md5
sudo wget https://download.nextcloud.com/server/releases/latest-27.tar.bz2.sha256
Verify the MD5 or SHA256 sum:
md5sum -c latest-27.tar.bz2.md5 < latest-27.tar.bz2
sha256sum -c latest-27.tar.bz2.sha256 < latest-27.tar.bz2
复制到"/var/www/"目录下
tar -xvf latest-27.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
配置Nextcloud
登陆:http://ip/nextcloud
根据提示配置就行。
安装应用:
仪表盘:
安装nextcloud office
点击右上角的用户图标,然后点击"管理设置",在右侧导航条管理中再点击"Office"。
这里使用内建的,这是配制好的效果,没有配制好时红色框中会有个提示:php -d memory_limit=512M occ app:install richdocumentscode
我用的命令是:sudo -u www-data php -d memory_limit=512M /var/www/nextcloud/occ app:install richdocumentscode
问题
这里的问题是V1版本的问题,我不知道V2版本是否会遇到,仅供参考
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' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'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
参考:
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