centos7搭建nextcloud个人网盘
(简易教程)centos7搭建nextcloud个人网盘
nextcloud推荐在LAMP环境使用,所有得准备好lamp环境。我这里准备的是cenots7/8 , php7.4 , mariadb ,和使用redis做缓存。
cenots使用最小化安装,
首先,安装好yum/dnf源,加上epel源,这里不做赘述。(我使用的是阿里云的源)
安装一些基础包:
[root@bak ~]# yum install -y epel-release yum-utils unzip curl wget bash-completion policycoreutils-python-utils mlocate bzip2
#更新一下包
[root@bak ~]# yum -y update
1.安装apache
[root@bak ~]# yum install -y httpd
配置虚拟主机:
新建配置文件/etc/httpd/conf.d/nextcloud.conf
,往里面加入下面的配置
<VirtualHost *:80>
DocumentRoot /var/www/html/nextcloud/
ServerName your.server.com
<Directory /var/www/html/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
</VirtualHost>
启动httpd,并开机自启
[root@bak ~]# systemctl enable --now httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
2.安装php
配置php的存储库
[root@bak ~]# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@bak ~]# yum-config-manager --enable remi-php74
安装php及扩展
[root@bak ~]# yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis php-opcache php-pecl-apcu php-intl php-process php-imagick php-gmp
#中途下载后需要验证,输入即可
#完成后可将php.ini的memory_limit调高,默认128M
3.安装数据库
[root@bak ~]# yum install -y mariadb mariadb-server
[root@bak ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
初始化
[root@bak ~]# mysql_secure_installation
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
创建nextcloud使用的数据库
[root@bak ~]# mysql -uroot -p
Enter password:
MariaDB [(none)]> create database nextcloud;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nextcloud.* to 'nextcloud'@'%' identified by 'nextcloud';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4.安装redis
[root@bak ~]# yum install -y redis
[root@bak ~]# systemctl enable --now redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
5.配置nextcloud
上传nextcloud,解压
[root@bak ~]# ls
anaconda-ks.cfg nextcloud-20.0.1.zip
[root@bak ~]# unzip nextcloud-20.0.1.zip
复制到虚拟主机路径
[root@bak ~]# cp -R nextcloud/ /var/www/html/
创建数据目录
[root@bak ~]# mkdir /var/www/html/nextcloud/data
给apache有nextcloud的权限
[root@bak ~]# chown -R apache:apache /var/www/html/nextcloud
重启服务
systemctl restart httpd.service
通过IP访问,配置好管理员和数据库账户密码
6.配置redis
完成web界面配置后,将生成/var/www/html/nextcloud/config/config.php
把下面的redis配置加入这个文件(不知道在哪就加载文件末尾的);
的上一行)
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\APCu',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),
重启服务
[root@bak ~]# systemctl restart httpd
[root@bak ~]# systemctl restart redis
查看redis
[root@bak ~]# redis-cli
127.0.0.1:6379> keys *
1) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/core/458e-6468-css-variables.css"
2) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-photos-favicon-mask.svg"
3) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-activity-favicon.ico"
4) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2text-232d-6468-icons.css.deps"
5) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/logout.svg"
6) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-places/files.svg"
7) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-settings-admin.svg"
8) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-activity-activity.svg"
9) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-user_status-app.svg"
10) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/photos/62ab-6468-icons.css"
11) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-firstrunwizard-apps/groupfolders.svg"
12) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-files-favicon-touch.png"
13) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2core-458e-6468-css-variables.css.deps"
14) "a50c55cb49086203752b976ed6b19d74/theming-http://10.11.114.12shouldReplaceIcons"
15) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-files-app.svg"
16) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/share.svg"
17) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-dashboard-favicon-touch.png"
18) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/dashboard/d149-6468-dashboard.css"
19) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-activity-favicon-touch.png"
20) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-places/contacts.svg"
21) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-settings-users.svg"
22) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-files-favicon.ico"
23) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-photos-favicon-touch.png"
24) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2activity-c4f1-6468-style.css.deps"
25) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-photos-manifest.json"
26) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-logo/logo.svg"
27) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-settings-apps.svg"
28) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-firstrunwizard-apps/tasks.svg"
29) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-photos-favicon.ico"
30) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-activity-activity-dark.svg"
31) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2files_sharing-4039-6468-icons.css.deps"
32) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-activity-favicon-mask.svg"
33) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/checkmark.svg"
34) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-photos-app.svg"
35) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2photos-62ab-6468-icons.css.deps"
36) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/user_status/47cd-6468-user-status-menu.css"
37) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-firstrunwizard-apps/social.svg"
38) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/notifications/0577-6468-styles.css"
39) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-settings-help.svg"
40) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/user.svg"
41) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-dashboard-manifest.json"
42) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2dashboard-d149-6468-dashboard.css.deps"
43) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-filetypes/video.svg"
44) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-logo/logo.png"
45) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2user_status-47cd-6468-user-status-menu.css.deps"
46) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-filetypes/application-pdf.svg"
47) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-dashboard-dashboard.svg"
48) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/activity/c4f1-6468-style.css"
49) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-filetypes/folder.svg"
50) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-places/calendar.svg"
51) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-files-manifest.json"
52) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/comment.svg"
53) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-firstrunwizard-info.svg"
54) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/core/458e-6468-server.css"
55) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-firstrunwizard-apps/deck.svg"
56) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/files/d71e-6468-merged.css"
57) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-filetypes/x-office-document.svg"
58) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/text/232d-6468-icons.css"
59) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-activity-manifest.json"
60) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/star-dark.svg"
61) "a50c55cb49086203752b976ed6b19d74/theming-http://10.11.114.12getScssVariables"
62) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-firstrunwizard-apps/notes.svg"
63) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-dashboard-favicon.ico"
64) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-files-add-color.svg"
65) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-dashboard-favicon-mask.svg"
66) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-background.png"
67) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2notifications-0577-6468-styles.css.deps"
68) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-files-favicon-mask.svg"
69) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2core-458e-6468-server.css.deps"
70) "a50c55cb49086203752b976ed6b19d74/imagePath-e7da93d63304cc862fc6857840bb5ca2-core-actions/delete.svg"
71) "a50c55cb49086203752b976ed6b19d74/SCSS-deps-e7da93d63304cc862fc6857840bb5ca2files-d71e-6468-merged.css.deps"
72) "a50c55cb49086203752b976ed6b19d74/SCSS-cached-e7da93d63304cc862fc6857840bb5ca220.0.1.1/files_sharing/4039-6468-icons.css"
。。。。。省略。。。。。。
还有其他一些优化,官网和网上也能找到,作为个人使用已经完全足够
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库