{"id":651,"date":"2012-08-26T19:51:02","date_gmt":"2012-08-26T18:51:02","guid":{"rendered":"http:\/\/blogs.gentoo.org\/scarabeus\/?p=651"},"modified":"2017-12-22T10:23:41","modified_gmt":"2017-12-22T09:23:41","slug":"running-owncloud-on-gentoo-stable","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/scarabeus\/2012\/08\/26\/running-owncloud-on-gentoo-stable\/","title":{"rendered":"Running owncloud on Gentoo stable"},"content":{"rendered":"<p>As I migrated to clean data layout (see previous post) I decided to be cool&#038;trendy guy and fire up my own lovely cloudy service.<\/p>\n<p>First my thinking was bit off regular setup, because even if we have in-tree ebuild of owncloud it hard-requires apache, which I find overkill here.<\/p>\n<p>So I introduce you to secret approach how to make it work with ngnix and sqlite3. Before you say that I should use *insertothercooldbname* please think of that my deployment is only for handfull users and I tested it with 5 users connected at once each of them having access to 1 tb shared datastore and it proven fast enough.<\/p>\n<h2>Preparing keywords\/useflags\/etc<\/h2>\n<p>Well owncloud is testing, so unmask it:<\/p>\n<pre>scarabeus@htpc: \/etc\/portage $ cat package.keywords\/own-cloud\r\nwww-apps\/owncloud<\/pre>\n<p>We need dav for direct access and php stuff for the setup (some useflags might be useless or redundant):<\/p>\n<pre>scarabeus@htpc: \/etc\/portage $ cat package.use\/own-cloud\r\ndev-lang\/php pdo sqlite3 curl xmlwriter gd truetype cgi force-cgi-redirect fpm\r\nwww-servers\/nginx nginx_modules_http_dav<\/pre>\n<p>Now silently punt the apache away as we love nginx:<\/p>\n<pre>scarabeus@htpc: \/etc\/portage $ cat make.profile\/package.provided\r\nvirtual\/httpd-php-5.4<\/pre>\n<p>And put all this to good use by emerging required stuff:<\/p>\n<pre>emerge -v www-servers\/nginx www-apps\/owncloud<\/pre>\n<h2>Setting up the stuff<\/h2>\n<p>As nginx does not have any fcgi we will use the fpm from php directly. For that we need to add it to runlevel <code>rc-update add php-fpm default<\/code> and set up a bit default number of spawned servers (config is in <code>\/etc\/php\/fpm-php5.4\/php-fpm.conf<\/code>). Also remeber to set there proper user\/group there, or you won&#8217;t be able to store content in your cloud, just read from it.<\/p>\n<p>Then we set up the nginx (<code>\/etc\/nginx\/nginx.conf<\/code> and <code>\/etc\/nginx\/fastcgi_params<\/code>). To keep this short and easy I will just post the config I used and let you to google for other nginx variables.<br \/>\nFirst the conf file:<\/p>\n<pre>        server {\r\n                listen 80;\r\n                server_name hostname;\r\n                rewrite ^ https:\/\/$server_name$request_uri? permanent;  # enforce https\r\n        }\r\n\r\n        server {\r\n                listen 443;\r\n                server_name hostname;\r\n\r\n                ssl on;\r\n                ssl_certificate \/etc\/ssl\/nginx\/nginx.crt;\r\n                ssl_certificate_key \/etc\/ssl\/nginx\/nginx.key;\r\n\r\n                access_log \/var\/log\/nginx\/htpc.access_log main;\r\n                error_log \/var\/log\/nginx\/htpc.error_log info;\r\n\r\n                root \/var\/www\/htpc\/htdocs\/owncloud\/;\r\n\r\n                client_max_body_size 8M;\r\n                create_full_put_path on;\r\n                dav_access user:rw group:rw all:r;\r\n\r\n                index index.php;\r\n\r\n                location ~ ^\/(data|config|\\.ht|db_structure\\.xml|README) {\r\n                        deny all;\r\n                }\r\n\r\n                location \/ {\r\n                        rewrite ^\/.well-known\/host-meta \/public.php?service=host-meta last;\r\n                        rewrite ^\/.well-known\/carddav \/remote.php\/carddav\/ redirect;\r\n                        rewrite ^\/.well-known\/caldav \/remote.php\/caldav\/ redirect;\r\n                        rewrite ^\/apps\/calendar\/caldav.php \/remote.php\/caldav\/ last;\r\n                        rewrite ^\/apps\/contacts\/carddav.php \/remote.php\/carddav\/ last;\r\n                        rewrite ^\/apps\/([^\/]*)\/(.*\\.(css|php))$ \/index.php?app=$1&getfile=$2 last;\r\n                        rewrite ^\/remote\/(.*) \/remote.php\/$1 last;\r\n\r\n                        try_files $uri $uri\/ @webdav;\r\n                }\r\n\r\n                location @webdav {\r\n                        fastcgi_split_path_info ^(.+\\.php)(\/.*)$;\r\n                        fastcgi_pass 127.0.0.1:9000;\r\n                        include fastcgi_params;\r\n                        fastcgi_param HTTPS on;\r\n                }\r\n\r\n                location ~* ^.+.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {\r\n                        expires 30d;\r\n                        access_log off;\r\n                }\r\n\r\n                location ~ \\.php$ {\r\n                        fastcgi_split_path_info ^(.+\\.php)(\/.*)$;\r\n                        fastcgi_pass 127.0.0.1:9000;\r\n                        include fastcgi_params;\r\n                        fastcgi_index index.php;\r\n                        fastcgi_intercept_errors on;\r\n                        try_files $uri =404;\r\n                }\r\n        }\r\n<\/pre>\n<p>For the fcgi we also need some params to make the webdav work:<\/p>\n<pre>fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\nfastcgi_param   SCRIPT_NAME     $fastcgi_script_name;\r\nfastcgi_param   PATH_INFO       $fastcgi_path_info;<\/pre>\n<p>That should be it, now we just deploy the owncloud to our webserver by webapp-config:<\/p>\n<pre>\/usr\/sbin\/webapp-config -I -h htpc -u root -d \/owncloud owncloud 4.0.7<\/pre>\n<p>After we start up the webserver and fcgi provider, we should be up and running to open the stuff in web browsers.<\/p>\n<h2>Few issues I didn&#8217;t manage to sort out in owncloud<\/h2>\n<ul>\n<li>External module to load all system users into it does not pass the auth<\/li>\n<li>Google sync just timeouts everytime I try it (I maybe have just damn huge content here)<\/li>\n<li>External storage support from within owncloud didn&#8217;t work for me, I just symlinked the data folder to the proper places under each user and logged into them in browser, then waited for 3 hours (1tb of data to index) and they were able to access everything.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>As I migrated to clean data layout (see previous post) I decided to be cool&#038;trendy guy and fire up my own lovely cloudy service. First my thinking was bit off regular setup, because even if we have in-tree ebuild of owncloud it hard-requires apache, which I find overkill here. So&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blogs.gentoo.org\/scarabeus\/2012\/08\/26\/running-owncloud-on-gentoo-stable\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":116,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[8],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/posts\/651"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/users\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":5,"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":784,"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/posts\/651\/revisions\/784"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/scarabeus\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}