Разлика между версии на „Инсталиране на OwnCloud под Ubuntu Server“
от БАРЗИКТ Wiki
(Нова страница: Category:servers [https://owncloud.org Официална страница на OwnCloud] =Обновяване на Ubuntu= <pre style="white-space: pre-wrap; wh...) |
|||
| Ред 18: | Ред 18: | ||
==Nginx и PHP== | ==Nginx и PHP== | ||
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | ||
| − | sudo apt-get install nginx php5-fpm | + | sudo apt-get install nginx php5-fpm php5-gd php5-curl |
</pre> | </pre> | ||
| Ред 26: | Ред 26: | ||
upload_max_filesize = 1G | upload_max_filesize = 1G | ||
post_max_size = 1G | post_max_size = 1G | ||
| + | </pre> | ||
| + | |||
| + | =Създаване на база данни за OwnCloud= | ||
| + | Стартира се '''sudo mysql -u root -p''' | ||
| + | <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | ||
| + | CREATE DATABASE owncloud; | ||
| + | GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'secret_password'; | ||
| + | flush privileges; | ||
| + | </pre> | ||
| + | |||
| + | =Генериране на сертификати за HTTPS= | ||
| + | <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | ||
| + | cd /etc/nginx | ||
| + | mkdir ssl | ||
| + | cd ssl | ||
| + | sudo openssl genrsa -des3 -out server.key 2048 | ||
| + | openssl req -new -key server.key -out server.csr | ||
| + | |||
| + | cp server.key server.key.org | ||
| + | openssl rsa -in server.key.org -out server.key | ||
| + | openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | ||
| + | </pre> | ||
| + | |||
| + | =Рестартиране на nginx и php5-fpm= | ||
| + | <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | ||
| + | sudo service nginx restart | ||
| + | sudo service php5-fpm restart | ||
| + | </pre> | ||
| + | |||
| + | =Изтегляне и дезархивиране на OwnCloud= | ||
| + | <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | ||
| + | sudo rm -rf /var/www/html | ||
| + | cd /var/www | ||
| + | sudo wget https://download.owncloud.org/community/owncloud-8.2.1.tar.bz2 | ||
| + | sudo bzip2 -d owncloud-8.2.1.tar.bz2 | ||
| + | sudo tar -xvf owncloud-8.2.1.tar | ||
| + | |||
| + | sudo chown www-data:www-data -R /var/www | ||
| + | </pre> | ||
| + | |||
| + | =Примерна конфигурация на nginx= | ||
| + | <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word"> | ||
| + | upstream php-handler { | ||
| + | server unix:/var/run/php5-fpm.sock; | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen 80; | ||
| + | server_name 192.168.1.208; | ||
| + | # enforce https | ||
| + | return 301 https://$server_name$request_uri; | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen 443 ssl; | ||
| + | server_name 192.168.1.208; | ||
| + | |||
| + | ssl_certificate /etc/nginx/ssl/server.crt; | ||
| + | ssl_certificate_key /etc/nginx/ssl/server.key; | ||
| + | |||
| + | # Path to the root of your installation | ||
| + | root /var/www/owncloud/; | ||
| + | # set max upload size | ||
| + | client_max_body_size 1G; | ||
| + | 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; | ||
| + | |||
| + | 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; | ||
| + | } | ||
| + | |||
| + | # 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; | ||
| + | } | ||
| + | } | ||
</pre> | </pre> | ||
Версия от 15:28, 2 декември 2015
Официална страница на OwnCloud
Съдържание
Обновяване на Ubuntu
sudo apt-get update sudo apt-get upgrade
Инсталиране на LEMP
MySQL
sudo apt-get install mysql-server php5-mysql sudo /usr/bin/mysql_secure_installation sudo apt-get install nginx php5-fpm
Nginx и PHP
sudo apt-get install nginx php5-fpm php5-gd php5-curl
Редактира се файла /etc/php5/fpm/php.ini, като се препоръчва да се направят следните промени:
cgi.fix_pathinfo=0 upload_max_filesize = 1G post_max_size = 1G
Създаване на база данни за OwnCloud
Стартира се sudo mysql -u root -p
CREATE DATABASE owncloud; GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'secret_password'; flush privileges;
Генериране на сертификати за HTTPS
cd /etc/nginx mkdir ssl cd ssl sudo openssl genrsa -des3 -out server.key 2048 openssl req -new -key server.key -out server.csr cp server.key server.key.org openssl rsa -in server.key.org -out server.key openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Рестартиране на nginx и php5-fpm
sudo service nginx restart sudo service php5-fpm restart
Изтегляне и дезархивиране на OwnCloud
sudo rm -rf /var/www/html cd /var/www sudo wget https://download.owncloud.org/community/owncloud-8.2.1.tar.bz2 sudo bzip2 -d owncloud-8.2.1.tar.bz2 sudo tar -xvf owncloud-8.2.1.tar sudo chown www-data:www-data -R /var/www
Примерна конфигурация на nginx
upstream php-handler {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name 192.168.1.208;
# enforce https
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name 192.168.1.208;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
# Path to the root of your installation
root /var/www/owncloud/;
# set max upload size
client_max_body_size 1G;
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;
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;
}
# 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;
}
}