<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-1a85854398.css"><div id="content_views" class="htmledit_views">
<p>1.安装Apache2和MariaDB</p>
sudo apt update
sudo apt install apache2 mariadb-server libapache2-mod-php7.4
sudo apt install php7.4-gd php7.4-mysql php7.4-curl php7.4-mbstring php7.4-intl
sudo apt install php7.4-gmp php7.4-bcmath php-imagick php7.4-xml php7.4-zip
2.数据库中创建nextcloud的数据库
sudo /etc/init.d/mysql startsudo mysql -uroot -p
登录数据库,并输入密码
成功登录后,创建nextcloud.
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 'username'@'localhost';
FLUSH PRIVILEGES;
quit;
上述有username可以任意设置,比如nextcloud,
password自己设置,比如123456,这只是示例
3.下载nextcloud
从这个网页下载https://nextcloud.com/install/#instructions-server, 有zip和gz等压缩包
wget https://download.nextcloud.com/server/releases/nextcloud-20.0.2.zip
unzip nextcloud-20.0.2.zip
sudo cp -r nextcloud /var/www
sudo chown -R www-data:www-data /var/www/nextcloud/
4.增加nextcloud.conf配置文件
sudo vi /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 -i
a2enmod rewrite
a2enmod headersa2enmod enva2enmod dira2enmod mime
a2enmod setenvif
Satisfy Any
service apache2 restart
再CTRL+C 退出root用户
5.如果开启SSL,也就是https
需要a2enmod ssla2ensite default-sslservice apache2 reload
同时/etc/apache2/sites-available/目录下的default-ssl.conf 文件中
修改SSLCertificateFile和SSLCertificateKeyFile的内容. 分别是pem和key的路径。这个是自己申请域名的SSL得到的证书和密钥
SSLCertificateFile xxxx.pem
SSLCertificateKeyFile yyyyy.key
6.访问http://domain/nextcloud进行nextcloud的配置