NextCloud 的安装依赖LAMP环境,即 Linux + Apache + MySQL(Mariadb) + PHP,所以在装 NextCloud前最好先装好这些,并且保证已经可用。
为了方便,本文在运行shell命令时都是以管理员用户身份运行(root权限下运行)!!!
具体步骤:
这里重申一下,为免麻烦,以下命令都是以管理员用户的身份运行的,root权限下执行的!
1. 开放防火墙
setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config
systemctl disable --now firewalld
reboot
2. 安装php 7.2 + apahce 运行环境
yum install centos-release-scl-rh -y
# yum search php
yum install rh-php72 -y
yum install rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-intl rh-php72-php-pecl-apcu -y
yum install rh-php72-php-mysqlnd -y
scl -l
scl enable rh-php72 "php -v"
scl enable rh-php72 bash
php -v
php -myum install -y httpd
systemctl start httpd
systemctl enabled httpdln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/systemctl restart httpd
下载NextCloud包
去 https://download.nextcloud.com/server/releases/nextcloud-20.0.1.zip 下载包并解压,放在 /var/html/www/ 目录改名为 nc.zip , 运行一键安装脚本:https://download.nextcloud.com/server/installer/setup-nextcloud.php,本机访问 http://192.168.76.89/setup-nextcloud.php
3,安装mysql数据库
yum -y install wget gcc gcc-c++ ncurses ncurses-devel cmake numactl.x86_64 libaio
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.7.24-linux-glibc2.12-x86_64/ /usr/local/mysql
cd /usr/local/mysql/
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cat >/etc/my.cnf <<EOF
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
port=3306
socket=/tmp/mysql.sock
skip-external-locking
key_buffer_size = 38M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
basedir=/usr/local/mysql
datadir=/var/lib/mysql
bind-address=0.0.0.0
innodb_flush_log_at_trx_commit=1
sync_binlog=1
log-bin=/var/lib/mysql/mysql_logbin
log-error=/var/log/mariadb
slow_query_log =1
slow_query_log_file=/tmp/mysql_slow.log
server-id=1
symbolic-links=0
[mysqld_safe]
pid-file=/var/run/mariadb/mariadb.pid
EOFuseradd mysql
mkdir -p /var/lib/mysql
chown mysql:mysql /var/lib/mysql
mkdir -p /var/log/mariadb
chown mysql:mysql /var/log/mariadb/
mkdir -p /var/run/mariadb
chown mysql:mysql /var/run/mariadb/
touch /var/run/mariadb/mariadb.pid
cat >> /etc/profile << EOF
export PATH=\$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
EOF
source /etc/profile
chmod -R 777 /var/log
mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize-insecure
/etc/init.d/mysql startmysql -u root -p
update mysql.user set authentication_string=password('123456') where user='root';
flush privileges;ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
登录NextCloud,创建管理员用户,访问:http://192.168.225.194/NextCloud/
【注意!】 图4这步包括以下内容:1. 创建owncloud的管理员用户(Create an admin account)。2. 数据存储文件夹(Data folder)。这里默认文件夹就可以了,不用管。 3. 配置数据库,包括数据库类型的选择,对应的用户、密码、数据库配置。这里默认是SQLite数据库类型,如果要用MySQL或者MariaDB的,这里一定要配置一下。如果忘记配置了,可以参考博文《如何将owncloud的数据库从SQLite迁移到MySQL/MariaDB》迁移数据库。
4 . 本机登录看看