廊坊新闻网-主流媒体,廊坊城市门户

当前看点!7环境下搭建私有云ownCloud详细教程

2022-07-24 09:47:52 来源:刀哥百科
使用阿里云搭建个人网盘

Nextcloud 是一款自由 (开源) 的类 Dropbox 软件,由 ownCloud 分支演化形成。它使用 PHP 和 JavaScript 编写,支持多种数据库系统,比如 MySQL/mariadb、PostgreSQL、Oracle 数据库和 SQLite。它可以使你的桌面系统和云服务器中的文件保持同步,Nextcloud 为 Windows、Linux、Mac、安卓以及苹果手机都提供了客户端支持。Nextcloud 并非只是 Dropbox 的克隆,它还提供了很多附加特性,如日历、联系人、计划任务以及流媒体 Ampache。


(资料图片)

本文简单讲述如何在云服务器配置Nextcloud实现个人网盘,仅供学习与交流,请勿用于商业用途

系统环境:阿里云 Centos7 无防火墙,无SElinux

一,配置PHP7-FPM

安装Nginx和php7

yum install epel-release -ynyum install nginx -y

添加webtatic仓库,里面提供了php7

rpm -Uvh https://www.dghbs.net/334230.html -y install php72w-fpm php72w-cli php72w-gd php72w-mysql php72w-pear php72w-mbstring php72w-pdo php72w-pecl-apcu php72w-pecl-apcu-devel php72w-intl.x86_64

配置php7-fpm修改配置文件,修改其用户和组为nginx

vim /etc/php-fpm.d/www.confn; Start a new pool named u0026#39;wwwu0026#39;.n[www]; Unix user/group of processesn; Note: The user is mandatory. If the group is not set, the default useru0026#39;s groupn; will be used.n; RPM: apache Choosed to be able to access some dir as httpdnuser = nginxn; RPM: Keep a group allowed to write in log dir.ngroup = nginx

检查php-fpm使用端口

; The address on which to accept fastcgi requests.n; Valid syntaxes are:n; u0026#39;ip.add.re.ss:portu0026#39; - to listen on a TCP socket to a specific IPv4 address o; a specific port;n; u0026#39;[ip:6:addr:ess]:portu0026#39; - to listen on a TCP socket to a specific IPv6 address o; a specific port;n; u0026#39;portu0026#39; - to listen on a TCP socket to all addressesn; (IPv6 and IPv4-mapped) on a specific port;n; u0026#39;/path/to/unix/socketu0026#39; - to listen on a unix socket.n; Note: This value is mandatory.nlisten = 127.0.0.1:9000

启动php-fpm

systemctl start php-fpmnsystemctl enable php-fpm二,配置 mariadb数据库

安装mariadb

yum install mariadb-server -y

启动服务并初始化

systemctl start mariadbnsystemctl enable mariadbnmysql_secure_installation

创建nextcloud数据库并授权给普通用户

create database nextcloud;ncreate user moulongxiong@localhost identified by u0026#39;long123u0026#39;;ngrant all privileges on nextcloud.* to moulongxiong@localhost identified by u0026#39;long123u0026#39;;nflush privileges;nquit;三,下载nextcloud

网络好就去nextcloud官网下载,网速慢从我的阿里云下载,如下所示

wget https://www.dghbs.net/334230.html

解压,并移动到web目录下

unzip nextcloud-18.0.3.zipnmv nextcloud/ /var/www/

更改nextcloud文件夹拥有者为nginx

chown nginx:nginx /var/www/nextcloud/四,在nginx配置nextcloud虚拟主机

官网有样板,改成自己的配置即可,我这里是80端口,不使用ssl

upstream php-handler {n server 127.0.0.1:9000;n #server unix:/var/run/php/php7.2-fpm.sock;n}server {n listen 80;n listen [::]:80;n server_name pan.doragon.xyz; # Remove X-Powered-By, which is an information leakn fastcgi_hide_header X-Powered-By; # Path to the root of your installatio root /var/www/nextcloud; location = /robots.txt {n allow all;n log_not_found off;n access_log off;n } # The following 2 rules are only needed for the user_webfinger app.n # Uncomment it if youu0026#39;re plaing to use this app.n #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;n #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; # The following rule is only needed for the Social app.n # Uncomment it if youu0026#39;re plaing to use this app.n #rewrite ^/.well-known/webfinger /public.php?service=webfinger last; location = /.well-known/carddav {n return 301 $scheme://$host:$server_port/remote.php/dav;n }n location = /.well-known/caldav {n return 301 $scheme://$host:$server_port/remote.php/dav;n } # set max upload sizen client_max_body_size 256M;n fastcgi_buffers 64 4K; # Enable gzip but do not remove ETag headersn gzip on;n gzip_vary on;n gzip_comp_level 4;n gzip_min_length 256;n gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;n gzip_types application/atom xml application/javascript application/json application/ld json application/manifest json application/rss xml application/vnd.geo json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest json application/xhtml xml application/xml font/opentype image/bmp image/svg xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # Uncomment if your server is build with the ngx_pagespeed modulen # This module is currently not supported.n #pagespeed off; location / {n rewrite ^ /index.php;n } location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {n deny all;n }n location ~ ^/(?:.|autotest|occ|issue|indie|db_|console) {n deny all;n } location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/. |oc[ms]-provider/. ).php(?:$|/) {n fastcgi_split_path_info ^(. ?.php)(/.*|)$;n set $path_info $fastcgi_path_info;n try_files $fastcgi_script_name =404;n include fastcgi_params;n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;n fastcgi_param PATH_INFO $path_info;n # fastcgi_param HTTPS on;n # Avoid sending the security headers twicen fastcgi_param modHeadersAvailable true;n # Enable pretty urlsn fastcgi_param front_controller_active true;n fastcgi_pass php-handler;n fastcgi_intercept_errors on;n fastcgi_request_buffering off;n } location ~ ^/(?:updater|oc[ms]-provider)(?:$|/) {n try_files $uri/ =404;n index index.php;n } # Adding the cache control header for js, css and map filesn # Make sure it is BELOW the PHP blockn location ~ .(?:css|js|woff2?|svg|gif|map)$ {n try_files $uri /index.php$request_uri;n add_header Cache-Control u0026#34;public, max-age=15778463u0026#34;; # Optional: Donu0026#39;t log access to assetsn access_log off;n } location ~ .(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {n try_files $uri /index.php$request_uri;n # Optional: Donu0026#39;t log access to other assetsn access_log off;n }n}

测试nginx文件正确性

nginx -t

启动nginx服务

systemctl start nginxnsystemctl enable nginx六,配置nextcloud

浏览器访问域名输入数据库用户名,数据库用户密码,数据库名称,数据库端口号即可完成配置

关键词: 个人网盘 数据库系统 虚拟主机