阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7上安装搭建ownCloud 9.1.4私有云

141次阅读
没有评论

共计 6487 个字符,预计需要花费 17 分钟才能阅读完成。

CentOS 7 上安装搭建 ownCloud 9.1.4 私有云

介绍

OwnCloud 9.1.4 是一种用于文件共享和数据同步的开源软件,在企业部门非常有用,你只需在服务器上安装好 ownCloud,即可通过网络访问和使用属于你自己的私有云了。

本教程是关于在 CentOS 7 上安装 ownCloud,Nginx 作为 Web 服务器。

安装 Nginx 和 PHP

首先,安装 Nginx。这个 Web 服务器在 EPEL 存储库中可用,所以只需添加它:

# yum install epel-release

接着:

# yum install nginx

接下来,使用 webtatic 存储库安装 PHP-FPM(FastCGI Process Manager),并添加以下命令:

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

现在可以使用 ownCloud 所需的其他软件包来安装 PHP:

# yum install php70w-fpm php70w-cli php70w-json  php70w-mcrypt  php70w-pear php70w-MySQL php70w-xml php70w-gd php70w-mbstring php70w-pdo

配置 Nginx 的 PHP-FPM

通过编辑 php7-fpm 配置文件完成 PHP-FPM 配置:

# $EDITOR /etc/php-fpm.d/www.conf

搜索包含“user”和“group”的那一行,并更改为:

user = nginx
group = nginx

向下滚动,寻找“listen”行,并将内容更改为:

listen = 127.0.0.1:9000

接下来,取消注释以下有关环境变量的行:

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

保存并退出。
现在,现在是使用以下命令在 /var/lib / 中创建一个新文件夹的时候了:

# mkdir -p /var/lib/php/session

将其所有者更改为 nginx 用户:

# chown nginx:nginx -R /var/lib/php/session/

启动 nginx 和 PHP-FPM:

# sudo systemctl start php-fpm
# sudo systemctl start nginx

添加到启动时启动(作为服务器的日常使用所需):

# systemctl enable nginx
# systemctl enable php-fpm

安装 MariaDB

MariaDB 在 CentOS 存储库中可用,因此请安装:

# yum install mariadb mariadb-server

配置 MariaDB root 密码:

# mysql_secure_installation

在此过程中,需要回答以下问题:

Set root password? [Y/n]
New password:
Re-enter new password:

Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

登录到 MariaDB shell,为 ownCloud 创建一个新的数据库和用户。在此示例中,my_owncloud_db 是数据库名称,ocuser 是其用户。密码是:my_strong_password。

所以执行命令:

# mysql -u root -p

接着:

mysql> CREATE DATABASE my_owncloud_db;
mysql> CREATE USER ocuser@localhost IDENTIFIED BY 'my_strong_password';
mysql> GRANT ALL PRIVILEGES ON my_owncloud_db.* to ocuser@localhost IDENTIFIED BY 'my_strong_passowrd';
mysql> FLUSH PRIVILEGES;

生成 SSL 证书

如果不存在,请为 SSL 文件创建一个新目录:

 
# mkdir -p /etc/nginx/cert/

接下来,生成一个新的 SSL 证书文件:

# openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/owncloud.crt -keyout /etc/nginx/cert/owncloud.key

使用以下命令更改权限:

# chmod 600 /etc/nginx/cert/*

现在 ownCloud

现在 ownCloud:

# wget https://download.owncloud.org/community/owncloud-9.1.4.zip

提取存档并将其移动到 /usr/share/nginx/html/:

# unzip owncloud-9.1.2.zip
# mv owncloud/ /usr/share/nginx/html/

转到 Nginx 根目录; 在那里,为 ownCloud 创建一个新的数据目录:

# cd /usr/share/nginx/html/
# mkdir -p owncloud/data/

在 Nginx 中配置虚拟主机

使用以下命令创建虚拟主机配置文件:

# $EDITOR /etc/nginx/conf.d/owncloud.conf

将以下文本粘贴到文件中:

 upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}
 
server {
    listen 80;
    server_name data.owncloud.co;
    # enforce https
    return 301 https://$server_name$request_uri;
}
 
server {
    listen 443 ssl;
    server_name storage.example.com;
 
    ssl_certificate /etc/nginx/cert/owncloud.crt;
    ssl_certificate_key /etc/nginx/cert/owncloud.key;
 
    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this topic first.
    add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
 
    # Path to the root of your installation
    root /usr/share/nginx/html/owncloud/;
 
    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;
 
    location = /.well-known/carddav {return 301 $scheme://$host/remote.php/dav;}
    location = /.well-known/caldav {return 301 $scheme://$host/remote.php/dav;}
 
    location /.well-known/acme-challenge { }
 
    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;
 
    # Disable gzip to avoid the removal of the ETag header
    gzip off;
 
    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;
 
    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;
 
    location / {rewrite ^ /index.php$uri;}
 
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {return 404;}
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {return 404;}
 
    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
        fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
        fastcgi_param front_controller_active true;
        fastcgi_pass php-handler;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
    }
 
    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri $uri/ =404;
        index index.php;
    }
 
    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~* \.(?:css|js)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into this topic first.
        #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets
        access_log off;
    }
 
    location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

保存并退出。接下来,测试 Nginx:

# nginx -t

This should display a“Syntax OK”message.

 

重启 Nginx:

# systemctl restart nginx

总结

服务器端配置完成。最后一件事是使用 Web 浏览器转到您自己的 Cloud 服务器 URL(本示例中为 storage.example.com),并使用图形前端完成配置。通过创建新的管理员帐户,并输入在前面的步骤中创建的数据库凭据来执行此操作。您的云端存储服务现在已准备好用于日常使用!

CentOS7 下 Nginx+ownCloud+PHP+MySQL 搭建个人私有云  http://www.linuxidc.com/Linux/2015-05/117086.htm

在 Ubuntu 上安装 OwnCloud 7.0.4  http://www.linuxidc.com/Linux/2015-01/111710.htm

红帽 RedHat7 使用 OwnCloud 10 搭建私有云  http://www.linuxidc.com/Linux/2017-06/14445.htm

Ubuntu/Debian/CentOS/Fedora/OpenSUSE 及衍生系统如何安装 OwnCloud 6 http://www.linuxidc.com/Linux/2014-06/102679.htm

CentOS7.2 搭建 ownCloud 私有云并启用 SSL  http://www.linuxidc.com/Linux/2017-02/141097.htm

Docker 环境中部署 OwnCloud 9.0  http://www.linuxidc.com/Linux/2016-12/138421.htm

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-07/145698.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计6487字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中