在阿里云上部署Nextcloud的记录
首先
我之前把它作为个人备忘录保存了大约半年,但由于草稿空间不足而进行了公开。
这是关于在阿里云的CentOS上搭建Nextcloud的简易备忘录。
最后,我还尝试了使用CEN从中国国内服务器进行连接的实验。
中间件安装

使用sudo yum install -y epel-release yum-utils unzip curl wget bash-completion policycoreutils-python mlocate bzip2安装必要的软件和工具。

请使用本地方式将以下内容翻译成中文,仅需提供一个版本:
请执行 “sudo yum update -y” 命令。

阿帕奇
使用sudo命令安装httpd软件,运行以下命令:
sudo yum -y 安装 httpd

请问您是需要将以下内容的意思以中文进行同义转述,只需要一种选项:
sudo systemctl enable httpd.service
sudo systemctl start httpd.service
可以使用以下方式进行转述:
启用httpd服务:sudo systemctl enable httpd.service
启动httpd服务:sudo systemctl start httpd.service

PHP可以被用来创建动态网页和服务器端脚本。
请使用sudo yum命令以-y选项安装centos-release-scl包。

使用sudo yum -y安装 rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-intl rh-php72-php-pecl-apcu rh-php72-php-mysqlnd rh-php72-php-pecl-redis rh-php72-php-opcache rh-php72-php-imagick。

请原生地用中文重新表达以下内容,只需要提供一种选项:
“sudo ln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/”
将/opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf软链接到/etc/httpd/conf.modules.d/。
用中文将以下内容转述一遍,只需要一种选项:
sudo ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/
使用超级用户权限,将/opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so软链接到/etc/httpd/modules/目录下。

我将检查符号链接。
列出 /etc/httpd/conf.d/rh-php72-php.conf 的详细信息
列出 /etc/httpd/conf.modules.d/15-rh-php72-php.conf 的详细信息
列出 /etc/httpd/modules/librh-php72-php7.so 的详细信息

请注意,以下是对指令的本地化翻译(只提供一种选择):
“`
sudo ln -s /opt/rh/rh-php72/root/bin/php /usr/bin/php
ls -la /usr/bin/php
“`
“`sudo ln -s /opt/rh/rh-php72/root/bin/php /usr/bin/php“`(将/opt/rh/rh-php72/root/bin/php软链接到/usr/bin/php)
“`ls -la /usr/bin/php“`(列出/usr/bin/php的详细信息)

数据库 (Databases)
使用curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash命令进行下载并在本地进行安装。

打开位于/etc/yum.repos.d/目录中的mariadb.repo文件。

请使用sudo yum安装MariaDB服务器和MariaDB客户端。

以中文本地化為:sudo systemctl 開啟 mariadb.service
sudo systemctl 啟動 mariadb.service.

也许需要以下命令…?
sudo mkdir -p /etc/mysql/mariadb.conf.d/
sudo mkdir -p /etc/mysql/conf.d/
Redis – Redis 是一个开源的内存键值数据库,它可用作缓存、数据库和消息中间件。
请执行以下命令,以安装Redis:
sudo yum install -y redis

启用Redis服务:sudo systemctl enable redis.service
启动Redis服务:sudo systemctl start redis.service

数据库配置
玛丽亚数据库
请参考
sudo cp -p /etc/my.cnf /etc/my.cnf.bak
sudo 复制 -p /etc/my.cnf /etc/my.cnf.bak
原始文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
请使用sudo权限打开/etc/my.cnf文件,编辑内容。
修改过的文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
transaction_isolation = READ-COMMITTED
binlog_format = ROW
innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=1
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[server]
skip-name-resolve
innodb_buffer_pool_size = 128M
innodb_buffer_pool_instances = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 32M
innodb_max_dirty_pages_pct = 90
query_cache_type = 1
query_cache_limit = 2M
query_cache_min_res_unit = 2k
query_cache_size = 64M
tmp_table_size= 64M
max_heap_table_size= 64M
slow-query-log = 1
slow-query-log-file = /var/log/mariadb/slow.log
long_query_time = 1
[client-server]
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
[client]
default-character-set = utf8mb4
请重新启动mariadb服务:sudo systemctl restart mariadb.service
PHP 配置
sudo cp -p /etc/opt/rh/rh-php72/php.ini /etc/opt/rh/rh-php72/php.ini.bak
使用sudo命令将/etc/opt/rh/rh-php72/php.ini复制到/etc/opt/rh/rh-php72/php.ini.bak文件中。
请使用 sudo vi /etc/opt/rh/rh-php72/php.ini,进行编辑。
# configuration for PHP MySQL module
extension=pdo_mysql.so
[mysql]
mysql.allow_local_infile=On
mysql.allow_persistent=On
mysql.cache_size=2000
mysql.max_persistent=-1
mysql.max_links=-1
mysql.default_port=
mysql.default_socket=/var/lib/mysql/mysql.sock # Debian squeeze: /var/run/mysqld/mysqld.sock
mysql.default_host=
mysql.default_user=
mysql.default_password=
mysql.connect_timeout=60
mysql.trace_mode=Off
密码设置:Zaq12wsx
mysql -uroot -p

在本地创建一个名为’nextcloud’的用户,密码设置为’password’。

如果没有存在,创建数据库nextcloud;

授予 ‘nextcloud’@’localhost’ 使用密码 ‘password’ ,在 nextcloud 数据库上具有选择、插入、更新、删除、创建、删除、索引、修改、创建临时表的权限。

刷新权限;

辞职

安装Nextcloud
请从这里下载。
请使用wget命令下载https://download.nextcloud.com/server/releases/nextcloud-16.0.1.zip。

解压缩 nextcloud-16.0.1.zip 文件。

使用sudo命令,将nextcloud文件夹复制到/var/www/html/目录下。

使用本地化中文进行改写,只需要一种选项:
sudo mkdir /var/www/html/nextcloud/data
sudo chown -R apache:apache /var/www/html/nextcloud
以超级用户身份创建目录/var/www/html/nextcloud/data,并将目录的所有权设置为apache用户组中的apache用户。

重新启动 httpd 服务。
下一代云存储访问



你可以从这里下载。

刚开始的时候是这样的感觉。

当你实际查看服务器的data文件夹时,你会发现同样的文件被放置在那里。

从Nextcloud界面上上传新文件后,服务器端的目录和文件都正确地增加了。

通过CEN连接的VPC之间的中国访问
我用这种配置从中国的服务器上进行了一次访问实验。

顺便提一下,如果不设置私有IP地址到 “trusted_domains” 中,将被视为不可信任的域名。

按照画面上的指示,编辑config.php文件。
首先要创建一个备份。
使用sudo cp -p /var/www/html/nextcloud/config/config.php /var/www/html/nextcloud/config/config.php.bak
编辑config.php文件。
使用sudo vi /var/www/html/nextcloud/config/config.php命令。
这是config.php未编辑之前的版本。
<?php
$CONFIG = array (
'instanceid' => '一意の識別子(さわるな危険)',
'passwordsalt' => '自動生成(さわるな危険)',
'secret' => '自動生成(さわるな危険)',
'trusted_domains' =>
array (
0 => '47.xxx.xxx.xxx',
),
'datadirectory' => '/var/www/html/nextcloud/data',
'dbtype' => 'mysql',
'version' => '16.0.1.1',
'overwrite.cli.url' => 'http://47.xxx.xxx.xxx/nextcloud',
'dbname' => 'データベース名',
'dbhost' => 'localhost:3306',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'データーベースユーザー',
'dbpassword' => 'データーベースユーザーパスワード',
'installed' => true,
);
编辑部分
'trusted_domains' =>
array (
0 => '47.xxx.xxx.xxx',
1 => '10.10.1.36',
),
保存文件后,再次访问即可登录状态。不需要重新启动服务。

我将尝试从中国上海的计算机上获取从日本上传的文件。


最后
我在阿里巴巴云上进行了一个小型的Nextcloud构建和访问实验。关于CEN,你也可以参考这个链接。