{"id":41236,"date":"2020-08-13T09:17:51","date_gmt":"2020-08-13T09:17:51","guid":{"rendered":"http:\/\/icloud.pe\/blog\/?guid=f44ce853c5fdad439064c513030aea1f"},"modified":"2020-08-13T09:17:51","modified_gmt":"2020-08-13T09:17:51","slug":"host-your-own-cloud","status":"publish","type":"post","link":"https:\/\/icloud.pe\/blog\/host-your-own-cloud\/","title":{"rendered":"Host your own cloud"},"content":{"rendered":"<p><span class=\"field field-name-field-author field-type-node-reference field-label-hidden\"><br \/>\n      <span class=\"field-item even\"><a href=\"https:\/\/www.cloudpro.co.uk\/authors\/nik-rawlinson\">Nik Rawlinson<\/a><\/span><br \/>\n  <\/span><\/p>\n<div class=\"field field-name-field-published-date field-type-datetime field-label-hidden\">\n<div class=\"field-items\">\n<div class=\"field-item even\"><span class=\"date-display-single\">13 Aug, 2020<\/span><\/div>\n<\/p><\/div>\n<\/div>\n<p class=\"short-teaser\">\n<a href=\"https:\/\/www.cloudpro.co.uk\/\" title=\"\" class=\"combined-link\"><\/a><\/p>\n<div class=\"field field-name-body\">\n<p dir=\"ltr\"><span>Are you continually running out of space on Dropbox, Google Drive or whatever your chosen cloud platform may be? If so, it\u2019s time to take matters into your own hands. Storing files on your own hardware lets you consolidate and synchronise your data without having to worry about storage limitations \u2013 and your privacy can also be better protected. Here\u2019s how to set up either a Raspberry Pi or a spare Windows PC as a personal cloud server, using the free ownCloud platform.<\/span><\/p>\n<h3 dir=\"ltr\"><span>Getting started with the Raspberry Pi<\/span><\/h3>\n<p dir=\"ltr\"><span>You can install and run ownCloud on a regular Raspberry Pi running Raspbian, but getting it working can be a little complicated, as you also need to install and configure web and database services.<\/span><\/p>\n<p dir=\"ltr\"><span>To simplify things, therefore, we\u2019ll ditch Raspbian and use the ultra-light DietPi OS distribution instead. This is based on Debian, like the official operating system, but it\u2019s designed to take up as little space as possible (a minimal installation tips the scales at just 400MB) and to streamline the process of installing core apps and services. Thus, when we install ownCloud on DietPi, the web server and database are also automatically installed and set up so that ownCloud can work from the word go.<\/span><\/p>\n<p dir=\"ltr\"><span>As DietPi is still a full, multitasking OS, you\u2019re free to install other services on it too. It makes a great starting point for a do-everything device that can live in a cupboard somewhere and perform a broad range of functions on your network \u2013 especially if you\u2019re using something as powerful as a Raspberry Pi 4.<\/span><\/p>\n<h3 dir=\"ltr\"><span>Download and install DietPi<\/span><\/h3>\n<p dir=\"ltr\"><span>To get the DietPi OS image, head to dietpi.com, scroll down to the Download section, click \u201cRaspberry Pi All models\u201d, then click the download icon next to Download Image.\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>The DietPi image is stored in 7Z format, which means it can\u2019t be unzipped with Windows\u2019 built-in tools. If you\u2019re not already running it, you can install 7-Zip (7-zip.org) to handle files of this type. Once you\u2019ve extracted the image, you\u2019ll need to write it onto your microSD card: there are plenty of tools that can do this, such as the official Raspberry Pi imager, which is a free download from raspberrypi.org\/download.<\/span><\/p>\n<p dir=\"ltr\"><span>Once you\u2019ve written the image to the card, you\u2019ll be told you can eject the card \u2013 but before doing this, we\u2019ll configure the Raspberry Pi to connect automatically to your wireless network, as this conveniently allows us to set up ownCloud remotely, without needing to hook the Pi up to a monitor and keyboard.<\/span><\/p>\n<p dir=\"ltr\"><span>To do this, open up your microSD card in Explorer and open the file dietpi.txt in Notepad. Find the line AUTO_SETUP_NET_WIFI_ENABLED=0 and change the last digit to 1. Save and close the file, then open dietpi-wifi.txt and look for the lines that say aWIFI_SSID[0]=&#8221; and aWIFI_KEY[0]=&#8221;. Enter your Wi-Fi network name between the first pair of quotes, and your password between the second.<\/span><\/p>\n<p dir=\"ltr\"><span>Now you can save the file, eject the microSD card, insert it in your Pi and let the Pi boot.<\/span><\/p>\n<h3 dir=\"ltr\"><span>Configure your Pi<\/span><\/h3>\n<p dir=\"ltr\"><span>Although you can set up DietPi and ownCloud directly on the Pi, we\u2019ll do it from a Windows system over SSH (the Secure Shell protocol). You need to know the Pi\u2019s IP address, which you should be able to find by checking the \u201cConnected devices\u201d list in your router\u2019s administration interface.<\/span><\/p>\n<p dir=\"ltr\"><span>Once you have got the address, open the command prompt on your Windows machine and type ssh root@x.x.x.x, entering the Pi\u2019s IP address in place of x.x.x.x. Windows will ask you to confirm you want to connect; type yes. Then enter the Pi root user\u2019s password, which defaults to dietpi. If you don\u2019t get in right away, perform a hard reboot of the Pi \u2013 we found this solved an issue when SSH seemed initially unresponsive.<\/span><\/p>\n<p dir=\"ltr\"><span>Once you\u2019re connected, the DietPi setup process will complete. We recommend you change the default passwords on the Pi when prompted \u2013 just make sure you pick something you can remember, as the passwords you choose will be used as the defaults for any installed applications. At the end of the process, you\u2019ll arrive at the DietPi-Software screen from which you can make further changes and install optimised apps.<\/span><\/p>\n<p dir=\"ltr\"><span>We suggest you start by assigning your Pi a static IP address to ensure your cloud server will always be accessible at the same address. To do this, key down to DietPi-Config and press Return, then key down to Network Options: Adapters and press Return again.<\/span><\/p>\n<p dir=\"ltr\"><span>Now key up to WiFi and press Return, then select Change Mode. Key down to Copy and press Return: the Pi will now always use your current IP address. In your router\u2019s management interface, set the address to \u201creserved\u201d to ensure that the router never tries to give it a different one.<\/span><\/p>\n<p dir=\"ltr\"><span>Press the right arrow key to select Ok, then press Return; finally, key down to Apply and press Return to restart the network service.<\/span><\/p>\n<h3 dir=\"ltr\"><span>Install ownCloud on the Pi<\/span><\/h3>\n<p dir=\"ltr\"><span>Now it\u2019s time to return to the DietPi-Software launch screen. This time key down to Software Optimised and press Return to open the list of available applications. It\u2019s a long list, including desktop GUIs, media centres, web servers, Spotify \u2013 and ownCloud, which you\u2019ll find as item 47 in the Cloud \/ Backups section. Press Space to select it, then Tab to highlight Ok and press Return.<\/span><\/p>\n<p dir=\"ltr\"><span>You\u2019ll be returned to the DietPi-Software screen. Key down to Install and press Return to download, unpack and set up ownCloud, along with the web server and database software on which it relies. When the process completes, let the Pi reboot.<\/span><\/p>\n<p dir=\"ltr\"><span>Once the Pi has restarted, switch back to your web browser, then type x.x.x.x\/owncloud, replacing \u201cx.x.x.x\u201d with your Pi\u2019s IP address. Use \u201cadmin\u201d for the username, with the password you set earlier (or \u201cdietpi\u201d if you didn\u2019t change the password) to log in.<\/span><\/p>\n<p dir=\"ltr\"><span>ownCloud is now up and running on your Pi, and the service should be accessible to any user on your local network. You can use it in a browser, or install the ownCloud desktop client, which runs on various versions of Linux as well as Windows and macOS \u2013 you\u2019ll find the installers at owncloud.org\/download. If you want to make ownCloud accessible from outside of your network, see opposite.\u00a0<\/span><\/p>\n<h3 dir=\"ltr\"><span>Setting up Apache on Windows<\/span><\/h3>\n<p dir=\"ltr\"><span>Setting up ownCloud on Windows is less straightforward than doing so on the Pi. In fact, ownCloud doesn\u2019t even work with some of the most popular web server and database packages on Windows. Luckily, Windows 10 includes the Windows Subsystem for Linux (WSL), which allows us to use Linux components instead.<\/span><\/p>\n<p dir=\"ltr\"><span>To get started, you might need to install the subsystem: to do this, right-click the Start button and select Windows PowerShell (Admin). When the UAC prompt appears, confirm that you want to make changes to your PC and then type this command into the PowerShell window:<\/span><\/p>\n<p dir=\"ltr\"><span>dism.exe \/online \/enable-feature \/featurename:Microsoft-Windows-Subsystem-Linux \/all \/norestart<\/span><\/p>\n<p dir=\"ltr\"><span>Once the subsystem is installed, check it\u2019s running by opening the Services console and selecting \u201cLxssManager\u201d: if it\u2019s not, right-click its name and select Restart from the menu.<\/span><\/p>\n<p dir=\"ltr\"><span>The next thing you need to do is install a Linux distribution. There are several to choose from in the Microsoft Store but, as we\u2019ve already set up ownCloud on a Debian-based system on the Pi, we\u2019ll use the Debian-based Ubuntu here. Use the search box in the Store app to locate Ubuntu and install it; when the installation completes, reboot your PC.<\/span><\/p>\n<p dir=\"ltr\"><span>Once your computer has restarted, reopen PowerShell with Admin rights and enter Ubuntu . The subsystem will perform some background tasks and then ask you to create a Unix user. Provide a username and password.\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>There\u2019s one last thing to do before you start downloading apps, and that\u2019s update the software catalogues: to do this, type sudo apt update and press Return (providing your password if requested).<\/span><\/p>\n<p dir=\"ltr\"><span>You can now install the Apache web server by typing sudo apt install apache2 -y and pressing Return. The -y switch tells Apache not to ask for confirmation, so the process will complete without interruption. When it\u2019s done, run the following commands, each on its own line, to enable the optional web server modules required by ownCloud:<\/span><\/p>\n<p dir=\"ltr\"><span>sudo a2enmod rewrite<\/span><\/p>\n<p dir=\"ltr\"><span>sudo a2enmod headers<\/span><\/p>\n<p dir=\"ltr\"><span>Now restart the Apache web server with sudo service apache2 restart. Check that the server is running properly by opening a browser window and pointing it at <a href=\"http:\/\/localhost\/\">http:\/\/localhost<\/a> \u2013 you should see the Apache2 Ubuntu Default Page.<\/span><\/p>\n<h3 dir=\"ltr\"><span>Setting up MariaDB<\/span><\/h3>\n<p dir=\"ltr\"><span>Now the web server is running, let\u2019s install the MariaDB database engine. You can do this by entering:<\/span><\/p>\n<p dir=\"ltr\"><span>sudo apt install mariadb-server mariadb-client<\/span><\/p>\n<p dir=\"ltr\"><span>Installation only takes a few seconds. When it\u2019s complete, enter these commands to start the database server and launch the configuration process:<\/span><\/p>\n<p dir=\"ltr\"><span>sudo \/etc\/init.d\/mysql start<\/span><\/p>\n<p dir=\"ltr\"><span>sudo mysql_secure_installation<\/span><\/p>\n<p dir=\"ltr\"><span>MariaDB will ask for the root password \u2013 but there isn\u2019t one yet, so just press Return and, when asked if you want to create a root password, press Y. Enter the new root password, press Return, then repeat the process.<\/span><\/p>\n<p dir=\"ltr\"><span>MariaDB will now ask if you want to delete anonymous users. Press Y then press it again when asked if you want to disallow remote login, and a third time to remove the test database. Finally, press Y to reload the tables; a moment later, you\u2019ll be ejected from the setup routine.<\/span><\/p>\n<p dir=\"ltr\"><span>Now log in using your new root account. Normally, you\u2019ll be able to do this by simply typing mysql -u root \u2013p. However, if you\u2019re denied access, you might need to update some permissions by entering the following commands on separate lines:\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>sudo mysql -u root<\/span><\/p>\n<p dir=\"ltr\"><span>use mysql;<\/span><\/p>\n<p dir=\"ltr\"><span>update user set plugin=&#8221; where User=&#8217;root&#8217;;<\/span><\/p>\n<p dir=\"ltr\"><span>flush privileges;<\/span><\/p>\n<p dir=\"ltr\"><span>exit;<\/span><\/p>\n<p dir=\"ltr\"><span>It should only be necessary to apply this fix once. Once you\u2019re in, create a database called \u201cowncloud\u201d by entering the following command at the MariaDB prompt:<\/span><\/p>\n<p><span><span>\u00a0<\/span><\/span><\/p>\n<p dir=\"ltr\"><span>CREATE DATABASE owncloud;<\/span><\/p>\n<p dir=\"ltr\"><span>You now need to make sure the root user can access your new database. Type the following and press Return, replacing PASSWORD with the password you created:<\/span><\/p>\n<p dir=\"ltr\"><span>GRANT ALL ON *.* to &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;PASSWORD&#8217;;<\/span><\/p>\n<p dir=\"ltr\"><span>Type \\q and press Return to quit the MariaDB prompt.\u00a0<\/span><\/p>\n<h3 dir=\"ltr\"><span>Setting up ownCloud on Windows<\/span><\/h3>\n<p dir=\"ltr\"><span>At last, it\u2019s time to download and install ownCloud. Switch to Apache\u2019s default web content folder by typing cd \/var\/www\/html; now point your web browser at download.owncloud.org\/community and check for the most recent build of ownCloud. At the time of writing, that was 10.4.1, but there may be a newer release by the time you read this.<\/span><\/p>\n<p dir=\"ltr\"><span>To download this, enter sudo wget <a href=\"https:\/\/download.owncloud.org\/community\/owncloud-10.4.1.zip\">https:\/\/download.owncloud.org\/community\/owncloud-10.4.1.zip<\/a>, changing the number to the latest version if appropriate.\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>Once the file has downloaded, you\u2019ll need to decompress it. First, install the unzip package with sudo apt install unzip -y, then enter sudo unzip -q owncloud-10.4.1.zip (again, changing the version number if required). This extracts the application to a subfolder called \u201cowncloud\u201d; switch to that now (by entering cd owncloud) and create a subfolder within it for your cloud data by entering sudo mkdir data.<\/span><\/p>\n<p dir=\"ltr\"><span>Finally, you need to set the appropriate permissions on the \u201cowncloud\u201d folder so it can be accessed and managed via ownCloud. To do this, enter the following two lines at the command prompt:<\/span><\/p>\n<p dir=\"ltr\"><span>sudo chown -R www-data:www-data \/var\/www\/html\/owncloud\/<\/span><\/p>\n<p dir=\"ltr\"><span>sudo chmod -R 755 \/var\/www\/html\/owncloud\/<\/span><\/p>\n<p dir=\"ltr\"><span>The ownCloud software is now fully installed\u2026 but, if you try to access it in a browser, you\u2019ll just see a listing of its index page. That\u2019s because we also need to install the PHP processor that interprets and renders the code \u2013 and before doing this, we need to add another software repository reference to the list of locations that Ubuntu checks when installing apps at the command line. To do all of this, enter each of the following lines in turn:<\/span><\/p>\n<p dir=\"ltr\"><span>sudo apt-get install software-properties-common\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>sudo add-apt-repository ppa:ondrej\/php\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>sudo apt update\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>sudo apt install php7.2 php7.2-cli php7.2-fpm php7.2-opcache php7.2-curl php7.2-mbstring php7.2-pgsql php7.2-zip php7.2-xml php7.2-gd php7.2-intl php7.2-mysql<\/span><\/p>\n<p dir=\"ltr\"><span>Finally, restart the web server by entering sudo service apache2 restart. Next, open a browser window and point it at localhost\/owncloud; you should now be given the ownCloud setup screen.\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>All that\u2019s left is a little bit of setup. Enter an admin username and password; these should preferably be different from those you set in MariaDB, as they\u2019ll only be used for logging in to ownCloud. Leave the data folder setting as it is, then in the four boxes below that deal with the database connection, use \u201croot\u201d for the username, your password, \u201cowncloud\u201d as the database name and \u201clocalhost\u201d as the host. Click the option to use MySQL\/MariaDB, followed by Finish Setup.<\/span><\/p>\n<p dir=\"ltr\"><span>The new user account will be created and ownCloud will deliver you to a login screen, where you can use the same username and password as you just specified to log in. As on the Raspberry Pi, you can now access ownCloud via the web from anywhere on your local network, or install the desktop client from owncloud.org\/download . If you want to be able to access your cloud remotely, then follow the steps below.<\/span><\/p>\n<h3 dir=\"ltr\"><span>Accessing your cloud remotely<\/span><\/h3>\n<p dir=\"ltr\"><span>When you first set up ownCloud, it will only be accessible within your local network. If you want to access it from the outside world, you\u2019ll need to configure your router to forward incoming web connections to the computer running your ownCloud server. On our Plusnet router, we achieved this by clicking Settings followed by Port Forwarding, then selecting \u201cHTTP Server (World Wide Web)\u201d from the Game or Service menu, and the name of the computer we want to direct it to from the Device menu. The process may be slightly different on your router, so you might need to dig through the menus.\u00a0<\/span><\/p>\n<p dir=\"ltr\"><span>Once you\u2019ve done this, you can connect to the computer hosting your ownCloud service by pointing a web browser at the external IP address of your router. However, ownCloud itself will, by default, only accept connections from within your network. To change this, navigate to the ownCloud configuration folder on your server (at \/var\/www\/owncloud\/config\/) and edit the config.php file. You can do this using the nano text editor by entering this command:<\/span><\/p>\n<p dir=\"ltr\"><span>sudo nano config.php<\/span><\/p>\n<p dir=\"ltr\"><span>Add the domain you just set up to the trusted_domains section at the top of the file. Press Ctrl+X to quit and press Y when asked if you want to write out the code to the existing file.<\/span><\/p>\n<p dir=\"ltr\"><span>You\u2019ll probably also want to sign up with a dynamic IP service, so you can access your ownCloud server by entering a memorable name, rather than a numeric address. There are several dynamic IP services to choose from, but we\u2019ll go with No-IP, which offers a convenient free plan. Sign up at noip.com by providing your email address and a password, and picking a suitable domain name \u2013 we chose pcpro.hopto.org. Confirm your email address by clicking the link it sends to your inbox; if you\u2019re using Windows, install the Dynamic Update Client using the provided link, so that it can notify the No-IP servers every time your router\u2019s IP address changes.<\/span><\/p>\n<p dir=\"ltr\"><span>If you\u2019re running ownCloud on DietPi, type dietpi-config at the command prompt and press Return to launch the setup tool. Key down to Network Options: Misc and press Return, then key to No-IP and press Return. Select Ok and press Return to set up the service. When it\u2019s finished installing, select the same No-IP option to set it up, then enter the email address and password you used to create your No-IP account. Your domain name will be detected and your IP address will be registered.<\/span><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>      Nik Rawlinson<\/p>\n<p>        13 Aug, 2020    <\/p>\n<p>      Are you continually running out of space on Dropbox, Google Drive or whatever your chosen cloud platform may be? If so, it\u2019s time to take matters into your own hands. Storing files on your own &#8230;<\/p>\n","protected":false},"author":418,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-41236","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/posts\/41236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/users\/418"}],"replies":[{"embeddable":true,"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/comments?post=41236"}],"version-history":[{"count":1,"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/posts\/41236\/revisions"}],"predecessor-version":[{"id":41237,"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/posts\/41236\/revisions\/41237"}],"wp:attachment":[{"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/media?parent=41236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/categories?post=41236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icloud.pe\/blog\/wp-json\/wp\/v2\/tags?post=41236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}