{"id":1774,"date":"2014-03-14T21:11:34","date_gmt":"2014-03-14T19:11:34","guid":{"rendered":"http:\/\/raftaman.net\/?p=1774"},"modified":"2021-05-15T11:46:37","modified_gmt":"2021-05-15T09:46:37","slug":"instaling-owncloud-with-nginx-and-php-fpm","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1774","title":{"rendered":"Instaling ownCloud with nginx and php-fpm"},"content":{"rendered":"<p>Setting up an <a href=\"http:\/\/owncloud.org\/\">ownCloud<\/a> instance is rather straight forward. OwnCloud6 rpm packages for recent Fedora versions (20+) already exist and can be easily installed with yum. Unfortunately, ownCloud&#8217;s storage mechanism is rather slow compared to other private cloud solution like <a href=\"http:\/\/seafile.com\">Seafile<\/a> or <a href=\"http:\/\/sparkleshare.org\/\">SparkleShare<\/a>. However the overall speed can be improved greatly by switching from the most obvious and most popular server choice &#8211; an apache server &#8211; to <a href=\"http:\/\/nginx.org\/\">nginx<\/a>, for example.<\/p>\n<p><!--more--><\/p>\n<h2>0. Installation prerequisites<\/h2>\n<p>Let&#8217;s start by installing the necessary packages:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# yum install owncloud owncloud-nginx php-fpm\r\n<\/pre>\n<h2>1. Setting up the database<\/h2>\n<p>Next, we need to set up a database backend for ownCloud, which can be either <a href=\"http:\/\/www.mysql.com\/\">MySQL<\/a> or <a href=\"http:\/\/www.postgresql.org\/\">PostgreSQL<\/a>. Since the MySQL comminity fork <a href=\"https:\/\/mariadb.org\/\">MariaDB<\/a> is officially part of Fedora, let&#8217;s use a MariaDB instance here:<\/p>\n<pre class=\"brush: bash; highlight: [1,3,4,7,17,20,23,26]; title: ; notranslate\" title=\"\">\r\n# systemctl enable mariadb.service \r\nln -s '\/usr\/lib\/systemd\/system\/mariadb.service' '\/etc\/systemd\/system\/multi-user.target.wants\/mariadb.service'\r\n# systemctl start mariadb.service \r\n# mysql_secure_installation \r\n&#x5B;...]\r\n\r\n# mysql --user=root --password\r\nEnter password: \r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 2\r\nServer version: 5.5.35-MariaDB MariaDB Server\r\n\r\nCopyright (c) 2000, 2013, Oracle, Monty Program Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB &#x5B;(none)]&gt; CREATE USER 'owncloud'@'localhost' IDENTIFIED BY 'password';\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nMariaDB &#x5B;(none)]&gt; CREATE SCHEMA owncloud CHARACTER SET utf8;\r\nQuery OK, 1 row affected (0.00 sec)\r\n\r\nMariaDB &#x5B;(none)]&gt; GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost';\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nMariaDB &#x5B;(none)]&gt; FLUSH PRIVILEGES;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n\r\nMariaDB &#x5B;(none)]&gt; quit\r\nBye\r\n<\/pre>\n<h2>2. Configuring nginx<\/h2>\n<p>Configuring the nginx backend is pretty simple. First, you have to allow clients from your subnet to access the nginx server by adding an appropriate access rule to the server section of the owncloud configuration file and change the server name to match your server&#8217;s <a href=\"http:\/\/en.wikipedia.org\/wiki\/Fully_qualified_domain_name\">FQDN<\/a>:<\/p>\n<pre class=\"brush: plain; highlight: [5,8]; title: \/etc\/nginx\/conf.d\/owncloud.conf; notranslate\" title=\"\/etc\/nginx\/conf.d\/owncloud.conf\">\r\n&#x5B;...]\r\nserver {\r\n#         listen 443 ssl;\r\n        listen 80;\r\n        server_name ownCloud;\r\n\r\n        allow 127.0.0.1;\r\n        allow 192.168.2.0\/24;\r\n        deny all;\r\n\r\n#         ssl_certificate \/etc\/ssl\/nginx\/cloud.example.com.crt;\r\n#         ssl_certificate_key \/etc\/ssl\/nginx\/cloud.example.com.key;\r\n\r\n        # Path to the root of your installation\r\n        root \/usr\/share\/owncloud\/;\r\n&#x5B;...]\r\n<\/pre>\n<p>Second, enable and start the nginx server as well as <a href=\"http:\/\/php-fpm.org\/\">PHP FastCGI Process Manager<\/a><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# systemctl enable php-fpm.service \r\nln -s '\/usr\/lib\/systemd\/system\/php-fpm.service' '\/etc\/systemd\/system\/multi-user.target.wants\/php-fpm.service'\r\n# systemctl start php-fpm.service\r\n# systemctl enable nginx.service \r\nln -s '\/usr\/lib\/systemd\/system\/nginx.service' '\/etc\/systemd\/system\/multi-user.target.wants\/nginx.service'\r\n# systemctl start nginx.service\r\n<\/pre>\n<p>And finally, open up your web browser and point it to your owncloud server. You should see ownCloud&#8217;s installation screen:<\/p>\n<div id=\"attachment_1780\" style=\"width: 453px\" class=\"wp-caption aligncenter\"><a data-rokbox data-rokbox-album=\"p1774\" data-rokbox-caption=\"ownCloud installation screen\" href=\"wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1780\" src=\"wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud1.png\" alt=\"ownCloud installation screen\" width=\"443\" height=\"655\" class=\"size-full wp-image-1780\" srcset=\"https:\/\/possiblelossofprecision.net\/wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud1.png 443w, https:\/\/possiblelossofprecision.net\/wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud1-371x550.png 371w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/a><p id=\"caption-attachment-1780\" class=\"wp-caption-text\">ownCloud installation screen<\/p><\/div>\n<p>If you click on <strong><em>Advanced<\/em><\/strong> you can fill in the details of your database connection:<\/p>\n<div id=\"attachment_1783\" style=\"width: 453px\" class=\"wp-caption aligncenter\"><a data-rokbox data-rokbox-album=\"p1774\" data-rokbox-caption=\"ownCloud advanced setup options\" href=\"wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1783\" src=\"wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud2.png\" alt=\"ownCloud advanced setup  options\" width=\"443\" height=\"989\" class=\"size-full wp-image-1783\" srcset=\"https:\/\/possiblelossofprecision.net\/wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud2.png 443w, https:\/\/possiblelossofprecision.net\/wordpress\/wp-content\/uploads\/2014\/02\/OwnCloud2-246x550.png 246w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/a><p id=\"caption-attachment-1783\" class=\"wp-caption-text\">ownCloud advanced setup options<\/p><\/div>\n<p>And if you confirm your settings with a click on <strong><em>Finish setup<\/em><\/strong> you should be redirected to ownCloud&#8217;s web UI.<\/p>\n<h2>3. Tuning the setup<\/h2>\n<p>To speed up ownCloud even further, you may want to look into <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_memcached_module.html\">nginx&#8217;s memchached module<\/a> and <a href=\"http:\/\/mysqltuner.com\/\">MySQLTuner<\/a>.<br \/>\nThere are also quite a few tutorials on nginx performance tuning out there, some of which have great tips on how to tune your nginx server for maximum performance. Among a lot of other things, you could reduce the <code>keepalive_timeout<\/code> and disable logging with <code>access_log off;<\/code> (both to be set in the nginx config file <code>\/etc\/nginx\/nginx.conf<\/code>).<\/p>\n<h2>4. Bug, bugs, bugs&#8230;<\/h2>\n<p>Unfortunately, there&#8217;s currently a bug in Fedora 20&#8217;s php package, which results in the <code>\/var\/lib\/php\/session\/<\/code> directory not being created when you install only nginx and the <a href=\"http:\/\/php-fpm.org\/\">PHP FastCGI Process Manager<\/a> as described above. This will create a redirection loop when you try to log into your owncloud web UI. You can either install the php interpreter package (wich owns <code>\/var\/lib\/php\/session\/<\/code>) with <code>yum install php<\/code> or create the directory manually:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# mkdir \/var\/lib\/php\/session\r\n# chown root:apache \/var\/lib\/php\/session\/\r\n# chmod 770 \/var\/lib\/php\/session\/\r\n# systemctl restart nginx.service\r\n<\/pre>\n<p>Don&#8217;t forget to restart the nginx server afterwards!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up an ownCloud instance is rather straight forward. OwnCloud6 rpm packages for recent Fedora versions (20+) already exist and can be easily installed with yum. Unfortunately, ownCloud&#8217;s storage mechanism is rather slow compared to other private cloud solution like Seafile or SparkleShare. However the overall speed can be improved greatly by switching from the most obvious and most popular&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1774\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,26],"class_list":["post-1774","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-fedora","tag-php"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1774"}],"version-history":[{"count":24,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1774\/revisions"}],"predecessor-version":[{"id":2189,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1774\/revisions\/2189"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}