1.Устанавливаем необходимые пакеты
1 |
# yum install httpd php php-mysql sqlite php-dom php-mbstring php-gd php-pdo wget |
2.Скачиваем и распаковываем дистрибутив owncloud
1 |
# wget https://download.owncloud.org/community/owncloud-7.x.x.tar.bz2 |
1 |
# tar xvfj owncloud-7.x.x.tar.bz2 -C /home/users/username/sitename/ |
1 |
# mv /home/users/username/sitename/owncloud/* /home/users/username/sitename/ |
3.Временно выставляем права 777 для установки owncloud
1 |
# chown -R username:username /home/users/username/sitename/ |
1 |
# chmod -R 777 /home/users/username/sitename/ |
4.Создаем базу и пользователя с доступом к этой базе
1 |
MariaDB [(none)]> create database cloud; |
1 |
MariaDB [(none)]> grant all privileges on cloud.* to 'clouduser'@'localhost' identified by 'cloudpassword'; |
1 |
MariaDB [(none)]> flush privileges; |
5.Настройка Web-сервера
Если используется Nginx+PHP-FPM
1 |
# nano /etc/nginx/conf.d/sitename.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
upstream php-handler { server unix:/var/run/php5-fpm.username.sock; } server { listen 80; server_name sitename; # enforce https return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name sitename; ssl_certificate /etc/nginx/ssl/sitename.pem; ssl_certificate_key /etc/nginx/ssl/sitename.key; access_log /var/log/nginx/sitename.access.log main; error_log /var/log/nginx/sitename.error.log; # Path to the root of your installation root /home/user/username/sitename; # set max upload size client_max_body_size 10G; fastcgi_buffers 64 4K; fastcgi_busy_buffers_size 192K; rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect; rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect; rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect; index index.php; error_page 403 /core/templates/403.php; error_page 404 /core/templates/404.php; location = /robots.txt { allow all; log_not_found off; access_log off; } location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){ deny all; } location / { # The following 2 rules are only needed with webfinger rewrite ^/.well-known/host-meta /public.php?service=host-meta last; rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; rewrite ^/.well-known/carddav /remote.php/carddav/ redirect; rewrite ^/.well-known/caldav /remote.php/caldav/ redirect; rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; try_files $uri $uri/ /index.php; } location ~ \.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_pass php-handler; fastcgi_index index.php; } # Optional: set long EXPIRES header on static assets location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { expires 30d; # Optional: Don't log access to assets access_log off; } } |
Если используется Apache
Apache(слушает 443 порт)
Проверка версии Apache
1 |
# apachectl -v | grep version |
1 |
Server version: Apache/2.2.15 (Unix) |
1 |
# nano /etc/httpd/conf.d/sitename.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<VirtualHost *:443> DocumentRoot /home/users/username/sitename ServerName sitename ServerAlias *.sitename SSLEngine on SSLCertificateFile /etc/httpd/ssl/sitename.perm SSLCertificateKeyFile /etc/httpd/ssl/sitename.key <Directory "/home/users/username/sitename"> Options Indexes FollowSymLinks AllowOverride All #apache 2.2 Order allow,deny allow from all #apache 2.4 Require all granted </Directory> ErrorLog logs/sitename-ssl-error.log CustomLog logs/sitename-ssl-access.log combined </VirtualHost> |
Если используется Nginx на 80 порту, тогда для принудительного перенаправления c http на https создаем вирт.хост для Nginx
1 |
# nano /etc/nginx/conf.d/sitename.conf |
1 2 3 4 5 6 |
server { listen <External_IP>:80; server_name sitename; # enforce https return 301 https://$server_name$request_uri; } |
Доступ к URL для установки owncloud
1 |
https://sitename |
6.Выставление корректных прав после установки
После установки проверяем от какого пользователя работает php
1 |
# nano /home/users/username/sitename/test.php |
1 |
<?php echo exec('whoami'); ?> |
1 |
https://sitename/test.php |
Ocpath – домашний каталог сайта sitename
Htuser – пользователь, под которым работает php
1 |
# nano /root/cloud.sh |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#!/bin/bash ocpath='/home/users/username/sitename' htuser='apache' find ${ocpath}/ -type f -print0 | xargs -0 chmod 0644 find ${ocpath}/ -type d -print0 | xargs -0 chmod 0755 chown -R root:${htuser} ${ocpath}/ chown -R ${htuser}:${htuser} ${ocpath}/apps/ chown -R ${htuser}:${htuser} ${ocpath}/config/ chown -R ${htuser}:${htuser} ${ocpath}/data/ chown root:${htuser} ${ocpath}/.htaccess chown root:${htuser} ${ocpath}/data/.htaccess chmod 0644 ${ocpath}/.htaccess chmod 0644 ${ocpath}/data/.htaccess |
1 |
# sh cloud.sh |
Файл конфигурации owncloud
1 |
/home/user/username/sitename/config/config.php |
Источник:
http://doc.owncloud.org/server/7.0/admin_manual
http://www.unixmen.com/install-owncloud-7-centos-7/
http://www.tecmint.com/install-owncloud-to-create-personal-storage-in-linux/