在Ubuntu Server 14.04上安装Owncloud 7(从源代码),PostgreSQL 9.3,PHP-FPM和NginX 64位

在Ubuntu Server 14.04 64位上安装Owncloud 7(源代码),PostgreSQL 9.3,PHP-FPM和NginX

版本1.0
作者:Sebastian Sasu

1.安装ubuntu服务器14.04 64位(不包括在本文中),并在软件选择中选择OpenSSH Server。 这样我们可以对服务器进行ssh访问。

重新启动后,将nginx存储库添加到/etc/apt/sources.list

sudo nano -wc /etc/apt/sources.list

2.在文件末尾添加以下内容:

# nginx stable 
deb http://nginx.org/packages/ubuntu/ trusty nginx 
deb-src http://nginx.org/packages/ubuntu/ trusty nginx 
# nginx mainline 
deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx 
deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx

3.更新您的软件

sudo apt-get update
sudo apt-get dist-upgrade

4.安装nginx

sudo apt-get install nginx

为自己的云安装neccesarry软件:

sudo apt-get install acl at-spi2-core ca-certificates-java colord cpp cpp-4.8 dbus-x11 dconf-gsettings-backend dconf-service default-jre default-jre-headless desktop-file-utils dictionaries-common fontconfig fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fonts-font-awesome fonts-liberation fonts-opensymbol fonts-sil-gentium fonts-sil-gentium-basic gconf-service gconf-service-backend gconf2 gconf2-common gdisk ghostscript gsfonts gvfs gvfs-common gvfs-daemons gvfs-libs heirloom-mailx hicolor-icon-theme hunspell-en-us icedtea-7-jre-jamvm imagemagick-common java-common javascript-common libao-common libao4 libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libasound2 libasound2-data libasyncns0 libatasmart4 libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libatspi2.0-0 libav-tools libavahi-client3 libavahi-common-data libavahi-common3 libavahi-glib1 libavcodec54 libavdevice53 libavfilter3 libavformat54 libavresample1 libavutil52 libbonobo2-0 libbonobo2-common libboost-date-time1.54.0 libboost-system1.54.0 libcaca0 libcairo-gobject2 libcairo2 libcanberra0 libcdio-cdda1 libcdio-paranoia1 libcdio13 libcdr-0.0-0 libcloog-isl4 libclucene-contribs1 libclucene-core1 libcmis-0.4-4 libcolamd2.8.0 libcolord1 libcolorhug1 libcups2 libcupsfilters1 libcupsimage2 libdatrie1 libdc1394-22 libdconf1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libexif12 libexttextcat-2.0-0 libexttextcat-data libfftw3-double3 libflac8 libfontconfig1 libfontenc1 libgconf-2-4 libgconf2-4 libgd3 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif4 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglu1-mesa libgmp10 libgnome2-0 libgnome2-bin libgnome2-common libgnomevfs2-0 libgnomevfs2-common libgomp1 libgphoto2-6 libgphoto2-l10n libgphoto2-port10 libgraphite2-3 libgs9 libgs9-common libgsm1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libgudev-1.0-0 libgusb2 libharfbuzz-icu0 libharfbuzz0b libhsqldb1.8.0-java libhunspell-1.3-0 libhyphen0 libice6 libicu52 libidl-common libidl0 libieee1284-3 libijs-0.35 libisl10 libjack-jackd2-0 libjasper1 libjbig0 libjbig2dec0 libjpeg-turbo8 libjpeg8 libjs-chosen libjs-dojo-core libjs-dojo-dijit libjs-dojo-dojox libjs-jcrop libjs-jquery libjs-jquery-metadata libjs-jquery-minicolors libjs-jquery-mousewheel libjs-jquery-tablesorter libjs-jquery-timepicker libjs-jquery-ui libjs-pdf libjs-sphinxdoc libjs-twitter-bootstrap libjs-underscore liblangtag-common liblangtag1 liblcms2-2 libldb1 libllvm3.4 liblqr-1-0 libltdl7 libmagickcore5 libmagickwand5 libmcrypt4 libmhash2 libmp3lame0 libmpc3 libmpfr4 libmspub-0.0-0 libmysqlclient18 libmythes-1.2-0 libneon27-gnutls libnspr4 libnss3 libnss3-1d libnss3-nssdb libntdb1 liboauth-php libogg0 libopenjpeg2 libopus0 liborbit-2-0 liborbit2 liborc-0.4-0 liborcus-0.6-0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpciaccess0 libphp-pclzip libphp-phpmailer libpixman-1-0 libpoppler44 libpulse0 libpython3.4 libraptor2-0 librasqal3 libraw1394-11 librdf0 libreoffice libreoffice-avmedia-backend-gstreamer libreoffice-base libreoffice-base-core libreoffice-base-drivers libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-gnome libreoffice-gtk libreoffice-impress libreoffice-java-common libreoffice-math libreoffice-pdfimport libreoffice-report-builder-bin libreoffice-sdbc-firebird libreoffice-sdbc-hsqldb libreoffice-style-galaxy libreoffice-style-human libreoffice-writer libsamplerate0 libsane libsane-common libschroedinger-1.0-0 libsdl1.2debian libsecret-1-0 libsecret-common libservlet3.0-java libsm6 libsmbclient libsndfile1 libspeex1 libswscale2 libtalloc2 libtdb1 libtevent0 libthai-data libthai0 libtheora0 libtidy-0.99-0 libtiff5 libtxc-dxtn-s2tc0 libudisks2-0 libv4l-0 libv4lconvert0 libva1 libvisio-0.0-0 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx1 libwayland-client0 libwayland-cursor0 libwbclient0 libwpd-0.9-9 libwpg-0.2-2 libwps-0.2-2 libx11-xcb1 libx264-142 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxfont1 libxft2 libxi6 libxinerama1 libxkbcommon0 libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxslt1.1 libxt6 libxtst6 libxv1 libxvidcore4 libxxf86dga1 libxxf86vm1 libyajl2 libzend-framework-php lp-solve mediawiki-classes mysql-common openjdk-7-jre openjdk-7-jre-headless owncloud-doc php-aws-sdk php-crypt-blowfish php-doctrine-common php-dompdf php-dropbox php-font-lib php-getid3 php-google-api-php-client php-guzzle php-irods-prods php-opencloud php-patchwork-utf8 php-pear php-phpdocx php-sabre-dav php-sabre-vobject php-seclib php-services-json php-symfony-console php-symfony-eventdispatcher php-symfony-routing php-tcpdf php-xml-parser php5 php5-apcu php5-cli php5-common php5-curl php5-gd php5-imagick php5-intl php5-json php5-ldap php5-mcrypt php5-mysql php5-oauth php5-readline php5-tidy php5-xsl policykit-1-gnome poppler-data python-crypto python-ldb python-ntdb python-samba python-talloc python-tdb python3-uno samba-common samba-common-bin samba-libs sdop smbclient sound-theme-freedesktop ssl-cert ttf-dejavu-core tzdata-java udisks2 uno-libs3 ure vorbis-tools x11-common x11-utils xfonts-encodings xfonts-mathml xfonts-utils zend-framework zend-framework-bin php5-pgsql postgresql-9.3 php5-fpm mc


6.禁用apache2

sudo update-rc.d -f apache2 disable


7.编辑postgresql pg_hba.conf

nano -wc /etc/postgresql/9.3/main/pg_hba.conf

您应该在文件中有这些条目

# Database administrative login by Unix domain socket 
local   all             postgres                                peer 
# TYPE  DATABASE        USER            ADDRESS                 METHOD 
# "local" is for Unix domain socket connections only 
local   all             all                                     trust 
# IPv4 local connections: 
host    all             all             127.0.0.1/32            md5 
# IPv6 local connections: 
host    all             all             ::1/128                 md5 
# Allow replication connections from localhost, by a user with the 
# replication privilege. 
#local   replication     postgres                                peer 
#host    replication     postgres        127.0.0.1/32            md5 
#host    replication     postgres        ::1/128                 md5


8.为OwnCloud 7(OC7)创建数据库

sudo su postgres
psql template1
psql (9.3.5)
Type "help" for help.

template1=# create user cloud with password 'pa55w0rd';
template1=# create database cloud template template0 encoding 'UNICODE';
template1=# alter database cloud owner to cloud;
template1=# grant all privileges on database cloud to cloud;
template1=# \q
$ exit
exit


9.下载owncloud:

cd /tmp
wget https://download.owncloud.org/community/owncloud-7.0.1.tar.bz2
tar jxvf owncloud-7.0.1.tar.bz2
mv owncloud /var/www/owncloud


10.配置nginx:

生成ssl证书:

mkdir -p /etc/ssl/nginx/ && cd /etc/ssl/nginx/
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nginx.key -out nginx.crt

编辑配置文件:

先备份您的nginx.conf文件,然后创建一个空的,具有以下内容:

sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
sudo nano -wc /etc/nginx/nginx.conf
#
user  www-data;
worker_processes  2; # Set this according to your number of CPU's

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
        worker_connections  1024;
        use epoll;
}

http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for"';

        access_log  /var/log/nginx/access.log  main;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        gzip on;
	  gzip_disable "msie6";
	  gzip_vary on;
	  gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_min_length 1000;
        gzip_buffers 4 32k;
        gzip_types text/plain application/x-javascript text/xml text/css application/xml;

include /etc/nginx/conf.d/*.conf;

upstream php-handler {
        server unix:/var/run/php5-fpm.sock;
}

}

为您的云创建一个配置文件:

mkdir /etc/nginx/conf.d
nano -wc /etc/nginx/conf.d/cloud.conf

将以下内容添加到cloud.conf中:

# Example taken form owncloud administrator manual
# http://goo.gl/63Mb9k
server {
        listen 80;
        server_name serverIP_or_FQDN;
        return 301 https://$server_name$request_uri;  # enforce https
}

server {
        listen 443 ssl spdy; # Activate SPDY for SSL connections
        server_name serverIP_or_FQDN;
        ssl_certificate /etc/ssl/nginx/nginx.crt;
        ssl_certificate_key /etc/ssl/nginx/nginx.key;
        # Path to the root of your installation
        root /var/www/owncloud/;

        client_max_body_size 10G; # set max upload size
        fastcgi_buffers 64 4K;
        client_body_buffer_size 2M;
        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_read_timeout 600; # Increase this to allow larger uploads
                access_log off; # Disable logging for performance
        }



        # Optional: set long EXPIRES header on static assets

        location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                expires 365d;
                # Optional: Don't log access to assets
                access_log off;
        }

}

在从浏览器进行OC7安装之前,先将owncloud目录的所有者更改为允许Web服务器对其进行读/写访问。

sudo chown -R www-data:www-data /var/www/owncloud

通过将浏览器指向https:// serverIP_or_FQDN /

输入您的管理员帐户的用户名和密码。

选择数据库类型(PostgreSQL),并输入前面创建的postgresql用户/数据库/密码。

文件上传的附加信息

PHP / PHP-FPM信息

对于大型上传(> 5GB),会增加超时限制:

对于php.ini编辑/etc/php5/fpm/php.ini并将默认执行时间从60秒更改为600:

max_execution_time = 600

对于php-fpm,将其添加到/ etc / nginx / conf.d / cloud.conf中

位置〜\ .php(?:$ | /){

...

fastcgi_read_timeout 600;

...

}

此外,您可以增加client_body_buffer_size以将nginx的缓冲限制为临时文件。 将其添加到您的nginx cloud.conf服务器指令中:

服务器{

听443 ssl spdy;

server_name serverFQDN;

...

client_body_buffer_size 2M;

...

}

使用ownCloud-client进行的1G上传将在服务器上传最后一个块后,在aprox 1分钟(60秒)内同步。 这与上传的大小几乎成正比。 所以对于一个2G文件,在上一个块上传后,会花费2分钟(120秒)来同步化。

上述设置将允许您上传5G文件,而无需“网关超时”问题,网络延迟为20-30ms。

链接

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏