웹사이트 검색

CentOS 7에서 Nginx 및 MariaDB와 함께 ownCloud 9.1을 설치하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 센트OS 7.3
  • 센트OS 7

이 페이지에서

  1. 전제 조건
  2. 1단계 - Nginx 및 PHP7-FPM 설치
  3. 2단계 - PHP7-FPM 구성
  4. 3단계 - MariaDB 설치 및 구성
  5. 4단계 - 자체 서명된 SSL 인증서 생성
  6. 5단계 - OwnCloud 다운로드
  7. 6단계 - Nginx에서 OwnCloud 가상 호스트 구성\n
  8. 7단계 - SELinux 및 방화벽 구성D\n
  9. 8단계 - OwnCloud 설치 마법사
  10. 참조

OwnCloud는 오픈 소스 라이선스로 제공되는 사용하기 쉬운 웹 기반 프런트엔드와 데이터 동기화 및 파일 공유를 위한 서버 소프트웨어입니다. OwnCloud는 Linux 또는 Windows 웹 서버에 설치할 수 있으며 구성하기 쉽고 포괄적인 온라인 설명서가 있습니다. 기본 클라이언트는 Windows, MacOS 및 Linux(데스크탑 애플리케이션)에서 사용할 수 있습니다. Android 및 iOS용 모바일 앱도 있습니다.

이 튜토리얼에서는 CentOS 7 서버에 ownCloud 9.1을 설치하고 구성하는 방법을 안내합니다. Nginx와 PHP 7(FPM으로) 및 MariaDB를 데이터베이스 시스템으로 사용하여 ownCloud를 구성하는 방법을 보여드리겠습니다.

전제 조건

  • CentOS 7 서버
  • 루트 권한\n

1단계 - Nginx 및 PHP7-FPM 설치

Nginx 및 php7-fpm 설치를 시작하기 전에 CentOS 기본 리포지토리에서 사용할 수 없는 추가 소프트웨어가 포함된 EPEL 리포지토리를 추가해야 합니다. 이 yum 명령으로 EPEL을 설치합니다.

yum -y install epel-release

이제 Epel 저장소에서 Nginx를 설치합니다.

yum -y install nginx

이제 우리는 php7-fpm을 위한 다른 저장소를 추가해야 합니다. 인터넷에서 사용할 수 있는 PHP 7용 저장소가 여러 개 있습니다. 여기서는 webtatic 저장소를 사용하겠습니다.

webtatic 저장소를 추가합니다:

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

다음으로 ownCloud 설치를 위한 몇 가지 추가 패키지와 함께 PHP7-FPM을 설치합니다.

yum -y install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json

서버 터미널에서 PHP 버전을 확인하여 성공적으로 설치되었는지 확인하십시오.

php -v

2단계 - PHP7-FPM 구성

이 단계에서는 nginx와 함께 실행되도록 php-fpm을 구성합니다. Php7-fpm은 사용자 nginx에서 실행되고 포트 9000에서 수신 대기합니다.

vim으로 기본 php7-fpm 구성을 편집합니다.

vim /etc/php-fpm.d/www.conf

8행과 10행에서 사용자와 그룹을 nginx로 변경합니다.

user = nginx
group = nginx

22행에서 php-fpm이 서버 포트 9000에서 실행 중인지 확인하십시오.

listen = 127.0.0.1:9000

php-fpm 시스템 환경 변수에 대한 366-370 행의 주석 처리를 제거하십시오.

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

파일을 저장하고 편집기를 종료합니다.

다음으로 /var/lib/ 디렉토리에 세션 경로에 대한 새 디렉토리를 생성하고 소유자를 nginx 사용자로 변경합니다.

mkdir -p /var/lib/php/session
chown nginx:nginx -R /var/lib/php/session/

php-fpm 및 nginx를 시작한 다음 부팅 시 시작하도록 추가합니다.

sudo systemctl start php-fpm
sudo systemctl start nginx

sudo systemctl enable php-fpm
sudo systemctl enable nginx

PHP7-FPM 구성이 완료되었습니다.

3단계 - MariaDB 설치 및 구성

OwnCloud는 PostgreSQL 및 MySQL 데이터베이스를 지원합니다. 이 자습서에서는 ownCloud 데이터베이스에 MariaDB를 사용합니다. yum 명령을 사용하여 CentOS 리포지토리에서 mariadb-server 패키지를 설치합니다.

yum -y install mariadb mariadb-server

MariaDB 서비스를 시작하고 MariaDB 루트 암호를 구성합니다.

systemctl start mariadb
mysql_secure_installation

요청 시 루트 비밀번호를 입력하십시오.

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

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

MariaDB 루트 암호가 설정되었으므로 이제 MySQL 셸에 로그인하여 ownCloud에 대한 새 데이터베이스 및 사용자를 생성할 수 있습니다. 새 데이터베이스를 생성합니다.

비밀번호가 [email 인 사용자 ownclouduser 아래에 새 데이터베이스 owncloud_db를 생성합니다. 설치를 위해 다른 안전한 암호를 선택하십시오!

mysql -u root -p
Type Password

아래에 MySQL 쿼리를 입력하여 새 데이터베이스와 새 사용자를 만듭니다.

create database owncloud_db;
create user ';
flush privileges;

사용자 ownclouduser가 포함된 owncloud_db 데이터베이스가 생성되었습니다.

4단계 - 자체 서명된 SSL 인증서 생성

이 튜토리얼에서는 클라이언트에 대한 https 연결에서 owncloud를 실행합니다. let encrypt와 같은 무료 SSL 인증서를 사용할 수 있습니다. 이 자습서에서는 OpenSSL 명령을 사용하여 나만의 SSL 인증서 파일을 생성합니다.

SSL 파일의 새 디렉터리를 만듭니다.

mkdir -p /etc/nginx/cert/

그런 다음 아래 OpenSSL 명령을 사용하여 새 SSL 인증서 파일을 생성합니다.

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

OpenSSL 명령에서 요청한 대로 SSL 인증서에 대한 세부 정보를 입력합니다. 그런 다음 chmod를 사용하여 모든 인증서 파일의 권한을 600으로 변경합니다.

chmod 600 /etc/nginx/cert/*

5단계 - OwnCloud 다운로드

wget 명령으로 ownCloud를 다운로드할 것이므로 먼저 wget 패키지를 설치해야 합니다. 또한 패키지 압축 해제가 필요합니다.

yum -y install wget unzip

tmp 디렉토리로 이동하여 wget을 사용하여 ownCloud 사이트에서 안정적인 최신 ownCloud 9.1을 다운로드하십시오.

cd /tmp
wget https://download.owncloud.org/community/owncloud-9.1.2.zip

ownCloud 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/

owncloud 디렉터리의 소유자를 nginx 사용자 및 그룹으로 변경합니다.

chown nginx:nginx -R owncloud/

6단계 - Nginx에서 OwnCloud 가상 호스트 구성

5단계에서는 ownCloud 소스 코드를 다운로드하고 Nginx 웹 서버에서 실행되도록 구성했습니다. 그러나 우리는 여전히 ownCloud에 대한 가상 호스트를 구성해야 합니다.

conf.d 디렉터리에 새 가상 호스트 구성 파일 owncloud.conf를 만듭니다.

cd /etc/nginx/conf.d/
vim owncloud.conf

아래에 ownCloud 가상 호스트 구성을 붙여넣으십시오.

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 data.owncloud.co;

    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
systemctl restart nginx

7단계 - SELinux 및 FirewallD 구성

이 자습서에서는 SELinux를 시행 모드로 유지하므로 이를 구성하려면 SELinux 관리 도구 패키지가 필요합니다.

이 yum 명령으로 SELinux 관리 도구를 설치하십시오.

yum -y install policycoreutils-python

그런 다음 아래 명령을 루트로 실행하여 ownCloud가 SELinux에서 실행될 수 있도록 합니다. ownCloud 설치에 다른 디렉토리를 사용하는 경우에는 ownCloud 디렉토리를 변경해야 합니다.

semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/owncloud/data(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/owncloud/config(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/owncloud/apps(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/owncloud/assets(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/owncloud/.htaccess'
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/owncloud/.user.ini'

restorecon -Rv '/usr/share/nginx/html/owncloud/'

다음으로 firewalld 서비스를 활성화하고 owncloud에 대한 HTTP 및 HTTPS 포트를 엽니다.

firewalld를 시작하고 부팅 시 시작되도록 구성합니다.

systemctl start firewalld
systemctl enable firewalld

firewall-cmd 명령으로 HTTP 및 HTTPS 포트를 연 다음 방화벽을 다시 로드합니다.

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

서버 구성 부분이 완료되었습니다.

8단계 - OwnCloud 설치 마법사

이제 웹 브라우저를 열고 ownCloud 도메인 이름을 URL 필드에 입력합니다. 내 이름은 data.owncloud.co이며 보안 HTTPS 연결로 리디렉션됩니다.

새 관리자 사용자 이름과 암호를 입력한 다음 데이터베이스 자격 증명을 입력하고 설정 완료를 클릭합니다.

관리 대시보드 파일 관리자.

사용자 설정.

관리자 설정.

Owncloud는 Nginx, PHP7-FPM 및 MariaDB와 함께 CentOS 7 서버에 성공적으로 설치되었습니다.

참조

  • https://doc.owncloud.org/