系统相关
首页 > 系统相关> > 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"
。。。。。省略。。。。。。

还有其他一些优化,官网和网上也能找到,作为个人使用已经完全足够

 

搭建常见问题:

1.搭建完成,无法访问,首先检查服务器防火墙是否关闭

2.出现下列问题

 

 

内部服务器错误

服务器发生一个内部错误并且无法完成你的请求.
如果多次出现这个错误, 请联系服务器管理员, 请把下面的技术细节包含在您的报告中.
更多细节可以在服务器日志中找到.

 

直入正题

这个问题的出现是由于文件夹权限设置的不到位。

如果直接简单地去设置权限,比如:

 

解决方式1:关闭selinux

解决方式2:

chown apache:apache nextcloud
chmod 770 nextcloud -Rf

 

那么你就会得到“内部服务器错误”的提示。

正确的做法是,

1.使用下面的配置脚本(这个脚本大概已经是第三遍被贴出来了):

随便找个地方(不要在Nextcloud的程序目录下),创建一个shell脚本:

 

vim permission.sh

 

然后把下面的内容粘贴进去(在vim中,你需要先按i,然后insert+shift键粘贴)

#!/bin/bash
ocpath='/var/www/nextcloud/'   #修改为你Nextcloud所放置的目录
htuser='apache'                #网页服务器用户
htgroup='apache'               #网页服务器的组
rootuser='root'

printf "Creating possible missing Directories\n"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater

printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ

printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
then
  chmod 0644 ${ocpath}/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
  chmod 0644 ${ocpath}/data/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi

 

按ESC键切换到普通模式,然后输入:wq保存退出。

2.关闭或正确地配置SELinux

临时的关闭可以用:

setenforce 0

永久关闭则可以编辑/etc/selinux/config 文件:

vim /etc/selinux/config

 

找到SELINUX=enforcing,将它改为SELINUX=disabled。

再刷新页面,错误信息就消失了:

 

 

解决过程

按CentOS中通常的步骤,YUM安装httpd、php、maraidb,然后下载Nextcloud的安装包,解压,简单地设置了一下权限,关掉防火墙、SELinux,然后浏览器里访问,提示错误。

如果上述步骤是在Debian/Ubuntu中做,现在已经可以看到安装界面了,而这个是什么情况?!

按提示中所说,错误记录在了日志里,于是检查了一下error.log(一般位于/etc/httpd/logs里,取决于你的配置),发现了这样的错误信息:

[Sat Nov 18 19:54:20.198935 2017] [php7:notice] [pid 24868] [client 192.168.3.66:65387] {"reqId":"WhAfbEVDNMLHuXKdeyBnUAAAAAI","level":3,"time":"2017-11-18T11:54:20+00:00","remoteAddr":"192.168.3.66","user":"--","app":"PHP","method":"GET","url":"\\/index.php","message":"chmod(): No such file or directory at \\/var\\/www\\/nextcloudtest\\/lib\\/private\\/Log\\/File.php#134","userAgent":"Mozilla\\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/62.0.3202.94 Safari\\/537.36","version":""}

呃………原来是一个PHP函数的报错。然而,chmod(): No such file or directory???

赶紧看下:

[root@imagineocean nextcloudtest]# ls lib/private/Log
ErrorHandler.php  Errorlog.php  File.php  Rotate.php  Syslog.php

这些文件明明好好地躺在那里!

第一反应是SELinux在捣鬼,于是检查了一下:

[root@imagineocean nextcloud]# getenforce
Permissive

 

转载:https://www.cnblogs.com/shipment/p/14011910.html

转载:解决CentOS中安装ownCloud/Nextcloud出现“内部服务器错误”-云码酷-综合自学教程 - Powered by 云码酷! (webzx.net)

标签:a50c55cb49086203752b976ed6b19d74,imagePath,网盘,centos7,svg,e7da93d63304cc862fc685
来源: https://www.cnblogs.com/dreammonkey/p/16263622.html