个人云服务器(使用阿里云搭建个人网盘)

使用阿里云搭建个人网盘Nextcloud 是一款自由 (开源) 的类 Dropbox 软件,由 ownCloud 分支演化形成。它使用 PHP 和 JavaScript 编写,支持多种数据库系统,比如 MySQL/MariaDB、PostgreSQL、Oracle 数据库和 SQLite。它可以使你的桌面系统和云服务器中的文件保持同步,Nextcloud 为 Windows、Linux、Mac、安卓以及苹果手机都提供了客户端支持。Nextcloud 并非只是 Dropbox 的克隆,它还提供了很多附加特性,如日历、联系人、计划任务以及流媒体 Ampache。本文简单讲述如何在云服务器配置Nextcloud实现个人网盘,仅供学习与交流,请勿用于商业用途系统环境:阿里云 Centos7 无防火墙,无SElinux一,配置PHP7-FPM安装Nginx和php7yum install epel-release -y
yum install nginx -y添加webtatic仓库,里面提供了php7rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -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修改配置文件,修改其用户和组为nginxvim /etc/php-fpm.d/www.conf
; Start a new pool named 'www'.
[www]

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx检查php-fpm使用端口; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' – to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' – to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' – to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' – to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000启动php-fpmsystemctl start php-fpm
systemctl enable php-fpm二,配置 mariadb数据库安装mariadbyum install mariadb-server -y启动服务并初始化systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation创建nextcloud数据库并授权给普通用户create database nextcloud;
create user moulongxiong@localhost identified by 'long123';
grant all privileges on nextcloud.* to moulongxiong@localhost identified by 'long123';
flush privileges;
quit;三,下载nextcloud网络好就去nextcloud官网下载,网速慢从我的阿里云下载,如下所示wget http://blog.doragon.xyz/files/nextcloud-18.0.3.zip解压,并移动到web目录下unzip nextcloud-18.0.3.zip
mv nextcloud/ /var/www/更改nextcloud文件夹拥有者为nginxchown nginx:nginx /var/www/nextcloud/四,在nginx配置nextcloud虚拟主机官网有样板,改成自己的配置即可,我这里是80端口,不使用sslupstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php/php7.2-fpm.sock;
}

server {
listen 80;
listen [::]:80;
server_name pan.doragon.xyz;

# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;

# Path to the root of your installation
root /var/www/nextcloud;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

# The following rule is only needed for the Social app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;

location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}

# set max upload size
client_max_body_size 256M;
fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
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 module
# This module is currently not supported.
#pagespeed off;

location / {
rewrite ^ /index.php;
}

location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
deny all;
}
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}

location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
# fastcgi_param HTTPS on;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}

location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
}

# Adding the cache control header for js, css and map files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";

# Optional: Don't log access to assets
access_log off;
}

location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}测试nginx文件正确性nginx -t启动nginx服务systemctl start nginx
systemctl enable nginx六,配置nextcloud浏览器访问域名输入数据库用户名,数据库用户密码,数据库名称,数据库端口号即可完成配置

本文出自快速备案,转载时请注明出处及相应链接。

本文永久链接: https://www.175ku.com/26648.html