记录一次ubuntu部署owncloud
目录
修改apt 源到阿里云
安装mysql、apache2、redis-server,并设置开机自启动
下载owncloud包
修改mysql密码与数据保存路径
?修改MySQL目录
?修改mysql启动文件,并修改apparomr访问规则
?重启服务并确认是否修改成功
安装PHP7.3
解压owncloud包到owncloud-data/,并修改属组
修改apache2 主目录
创建owncloud数据库用户并授权
修改owncloud使用redis
?重启apache2访问http://nodeIP:port进行初始化安装
修改apt 源到阿里云
vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
安装mysql、apache2、redis-server,并设置开机自启动
sudo apt-get update && sudo apt-get install mysql-server apache2 redis-server
systemctl enable apache2 && systemctl start apache2
systemctl enable mysql && systemctl start mysql
systemctl enable redis-server && systemctl start redis-server
下载owncloud包
wget https://download.owncloud.org/community/owncloud-complete-20210721.tar.bz2
修改mysql密码与数据保存路径
root@ubuntu:/etc/apache2# cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = BPB6oLl4G4hymEU0
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = BPB6oLl4G4hymEU0
socket = /var/run/mysqld/mysqld.sock
mysql -udebian-sys-maint -pBPB6oLl4G4hymEU0
#修改root密码
mysql> update user set authentication_string=password('ownMysql$123') where user='root';
mysql> update user set plugin='mysql_native_password' where user='root';
mysql> flush privileges;
mysql> show variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value |
+---------------+-----------------+
| datadir | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.01 sec)
?修改MySQL目录
#mysql新目录
sudo mkdir -p /owncloud-data/mysqld/data
cd /owncloud-data/mysqld/data
cp -rp /var/lib/mysql/* /owncloud-data/mysqld/data/
chown mysql.mysql -R /owncloud-data/mysqld/
chmod 700 -R /owncloud-data/mysqld/
root@owncloud:/owncloud-data# ll
total 12
drwxr-xr-x 3 root root 4096 Dec 22 01:38 ./
drwxr-xr-x 25 root root 4096 Dec 22 01:38 ../
drwx------ 3 mysql mysql 4096 Dec 22 01:38 mysqld/
#
#备份mysql配置文件
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.bak
vim /etc/mysql/mysql.conf.d/mysqld.cnf
#将datadir修改为新增加的目录/owncloud-data/mysqld/data
[mysqld]
28 #
29 # * Basic Settings
30 #
31 user = mysql
32 pid-file = /var/run/mysqld/mysqld.pid
33 socket = /var/run/mysqld/mysqld.sock
34 port = 3306
35 basedir = /usr
36 datadir = /owncloud-data/mysqld/data
37 tmpdir = /tmp
38 lc-messages-dir = /usr/share/mysql
39 skip-external-locking
?
?修改mysql启动文件,并修改apparomr访问规则
vim /etc/apparmor.d/usr.sbin.mysqld
#在50行左右添加
/owncloud-data/mysqld/data/ r,
/owncloud-data/msyqld/data/** rwk,
vim /etc/apparmor.d/tunables/alias
#最后一行添加
alias /var/lib/mysql/ -> /owncloud-data/mysqld/data/,
?
?重启服务并确认是否修改成功
systemctl restart apparmor
systemctl restart mysql
mysql -uroot -pownMysql$123
mysql> show variables like 'datadir';
+---------------+-----------------------------+
| Variable_name | Value |
+---------------+-----------------------------+
| datadir | /owncloud-data/mysqld/data/ |
+---------------+-----------------------------+
1 row in set (0.00 sec)
安装PHP7.3
#添加php源
apt -y install software-properties-common apt-transport-https lsb-release ca-certificates
add-apt-repository ppa:ondrej/php
sudo apt install php7.3 php7.3-bz2 php7.3-curl php7.3-gd php7.3-imagick php7.3-intl php7.3-mbstring php7.3-xml php7.3-zip libapache2-mod-php php7.3-mysql php7.3-redis -y
解压owncloud包到owncloud-data/,并修改属组
tar jxvf owncloud-complete-20211220.tar.bz2 -C /owncloud-data/
chown www-data.www-data -R /owncloud-data/owncloud/
修改apache2 主目录
vim /etc/apache2/sites-enabled/000-default.conf
DocumentRoot /owncloud-data/owncloud
#修改apache2.cnf
<Directory /owncloud-data/owncloud>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
创建owncloud数据库用户并授权
create databse owncloud_db;
grant all on owncloud_db.* to 'owncloud_user'@'localhost' identified by 'OwnCloud@!123$';
flush privileges;
修改owncloud使用redis
vim /owncloud-data/owncloud/config/config.php
###########添加以下配置
'memcache.local' => '\OC\Memcache\Redis',
'redis' => [
'host' => 'localhost',
'port' => 6379,
],
'memcache.locking' => '\OC\Memcache\Redis',
?重启apache2访问http://nodeIP:port进行初始化安装
?
|