Nextcloud on CentOS — host your own cloud

A lot of use cloud services. Cloud services can be used to sync between devices, but is also good for cooperation with colleagues. Most of us use clouds own by others, such as Google drive, Box or Dropbox. I for myself prefer to handle the cloud myself. In my opinion it should be easy to set up a server on an old computer and run your own cloud. I do that, I use a server program called Nextcloud, which I like very much. But I must say, as an amateur, it has not always been easy. There are manuals, one of the best of course is Nextclouds own. But the problem is the manuals are not always easy and that Nextcloud by it self is not enough. You also need to set up apache, mysql/mariadb and php (also called LAMP — Linux, Apache, Mysql, PHP). If you use an OS using SELinux you also need to handle this. You should also, for security, fix SSL-certificate. Unfortunately, I have not found a tutorial with all these collected together. Quite often tutorials on the internet require that you understand for example Apache.

In this article I will show you how to set up Nextcloud on CentOS 7. The Nextcloud version used is 16. Things may change between versions. Further, this is in no way a complete tutorial. But it will make you up an going. I would also recommend anyone finding this to not only using this article, but also look at Nextclouds manual for administrators.


The first thing you need is of course a computer that can be used as a server. An old laptop will most likely be enough, but you can also build one if you want to. Then you have to install CentOS on that computer. This article is not about installing CentOS — but it is really easy. You can download CentOS here. Then you burn it on a USB-stick. There are several ways to do this, but if you use a Linux distro with gnome you can use the disk application (use the restore image function).

All the commands here require that you are root. To become root you open the terminal and write


Enter your password and you should be root.

The first thing you need to do after installing CentOS is to update the system. CentOS use yum as package manager. If you use the -y flag you don’t need to confirm the update. If you want to confirm just skip the -y flag.

yum -y update

To be able to install LAMP you need the yum-utils packages (see more about it here). For me the yum-utils packages was already installed on the system. But to be on the safe side try to install the packages:
Install the ‘yum-utils’ package on your server to use ‘yum-config-manager’.

sudo yum -y install yum-utils

In this article I will show how to use wget to fetch Nextcloud from internet. Wget is not installed on the system, so you have to install it. I also installed Nano, a text editor. But if you know how to use vi and feel comfortable with that text editor, you of course do not need install nano.

yum -y install nano wget


I use mariadb instead of MySQL. MariaDB is a community developed fork of MySQL. But you can use either one. The commands used here are the same. The first thing we need to do is to install MariaDB.

yum -y install mariadb mariadb-server

After installing MariaDB you have to start it and enable it. MariaDB works as a service, and to start means just that. To enable MariaDB ensures that the service starts when the computer starts. This is handled by systemd.

systemctl start mariadb.service
systemctl enable mariadb.service

To make settings and secure the mysql-data base you need to run the mysql-secure-installation. In the terminal run:


… use the following set up:

Enter current password for root (enter for none): ENTER
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

After you have done this you can log into MariaDB and create database and user:

mysql -u root -p

You will be prompted to enter your password (which you create when running mysqlsecureinstallation)

In MariaDB you create database and user. Change user to whatever (admin for example):

MariaDB [(none)]> CREATE DATABASE nextcloud;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'YOURPASSWORD';
MariaDB [(none)]> \q

Apache server

Next you have to install the Apache Web Server. In the terminal:

yum install httpd -y

You have to configure a virtual host. Create a new file (here using nano) with the following set up. In the terminal:

nano /etc/httpd/conf.d/nextcloud.conf

The following set up works fine.

<VirtualHost *:80>
  DocumentRoot /var/www/html/

<Directory "/var/www/html/">
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

Start and enable Apache.

systemctl start httpd.service
systemctl enable httpd.service


Install PHP 7 — be shure to install at least php7.3. To do that you need to install the epel-release repository.

yum install epel-release

Install Remi and EPEL repository packages:

rpm -Uvh
rpm -Uvh

Enable Remi PHP 7 repo:

yum-config-manager --enable remi-php73

Install PHP and several PHP modules required by Nextcloud by executing the following command:

yum -y install php php73-php-fpm php-mysql php-pecl-zip php-xml php-mbstring php-gd

It is a good practice to check what version is running:

php -v

Next, open the PHP configuration file and increase the upload file size. You can find the location of the PHP configuration file by executing the following command:

php --ini |grep Loaded

This is what i saw form the command:

Loaded Configuration File:         /etc/php.ini

Thus, we have to make changes to the /etc/php.ini file. Here we increase the default upload limit to 100 MB. You can set the values according to your needs. Run the following commands:

sed -i "s/post_max_size = 8M/post_max_size = 100M/" /etc/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 100M/" /etc/php.ini

Create a file called info.php within the var/www/html directory with the following content:

<?php phpinfo(); ?>

Restart the web server:

systemctl restart httpd

Install Nextcloud 16

Go to Nextcloud’s official website and download the latest stable release of the application


Unpack the downloaded zip archive to the document root directory on your server

unzip -d /var/www/html/

Create data in the nextcloud directory

mkdir /var/www/html/nextcloud/data

Set the Apache user to be owner of the Nextcloud files

chown -R apache:apache /var/www/html/*


Settings in selinux

chcon -t httpd_sys_rw_content_t /var/www/html/nextcloud/ -R

Selinux can be totally disabled — but it is not necessary. To disable selinux change enabled to disabled in /etc/selinux/config.

nano /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.

Access Nextcloud

Finally, access Nextcloud at http://yourip/nextcloud (to see your ip-adress run ip addr in the terminal). The installation wizard will check if all requirements and if everything is OK, you will be prompted to create your admin user and select storage and database. Select MySQL/MariaDB as database and enter the details for the database we created earlier in this post:

User: nextclouduser
Database password: YOURPASSWORD
Database name: nextcloud
host: localhost

Debian on my secondary computer

I had Void on my secondary computer for a long time. However, the computer was partitioned in a problematic way — there was no room in root, while a lot in home. I therefore decided to try something else — and I have never installed Debian on a real machine (only in virutal machines). I installed the stable version and choosed xfce as desktop enviornment, and later on installed xfce4. I must say that computer runs great for the work I do on it.

Installing Vivaldi — the web browser

The first post of the year!

Vivaldi is a great web browser. In fact, it is so great that I now use it as my daily web browser. I will not write about why it is so great (now) — but how to install it. I am using Fedora, and Vivaldi is not in the repositories. So you either have to download it as a rpm from their website or install it through fedy. I used the last option. If you do that you evidently first need to install fedy. This is how you do that:

Go to this site

Copy the code in the terminal. You have to be superuser (sudo). After you have done that and the computer has done it’s thing you install Fedy the normal way:

sudo dnf install fedy

After you have installed Fedy open the application and install Vivaldi. It is easy, it is a graphical tool.

After installation you will have some problems. You will not be able to see HTML5-videos and not videos using Digital Rights Management (DRM),  for example Netflix. The solution to these problems can be found on ruario’s GitHub page. Regarding HTML5 see here.

If you are on Ubuntu, this is rather easy to fix. To enable HTML5 you need to download chromium-codecs-ffmpeg-extra, which is in the repositories

sudo apt update && sudo apt install chromium-codecs-ffmpeg-extra

If you are on Arch the codecs can be found in AUR: vivaldi-ffmpeg-codecs.

If you are not in Ubuntu or Arch it is a little more problematic. But ruario has written a bash-script that works just perfect. On the GitHub page it is also described what is happening. So just scroll down and copy the script. Save it and make it executable. If you have named the file in accordance to rurario’s suggestion (, open the terminal, go to the directory where you want to have the file and enter:

chmod +x

Execute the file


After you have restarted Vivalid you can see movies on for exampel YouTube.

But you still cannot see movies on Netflix. To be able to do that you will need Widevine. rurario has also written a bash-file the fetch that program. Follow the same instructions as above, but using these codes instead. After that you restart the browser and you will be able to see movies on Netflix.

Choose drive to Boot in Macbook Pro

I have a Macbook pro mid 2014 on which a double boot Fedora and MacOS. I mainly use the Fedora partition, and the computer boot in to Fedora as default. But I recently noticed that the system changes the default boot drive when updating MacOS. This is a bit strange since I also have a Macbook pro 2012, where the system does not change the default boot drive. There is anyhow easy to change the default boot drive on the Macbook pro. When firing up the computer press Alt until you come to a screen showing the drives.

Use the arrows to choose the drive. Press ctrl. You will now see a circle with and arrow. Press return to boot into the system. Next time you fire up the computer it will default with the drive you press ctrl over last time.

Sorry for the poor quality of this picture!

Markdown is a practical tool


Markdown is a simplified way of writing HTML-code. I have not engaged myself especially much in markdown. Yes, I have heard about, especially in relation to RStuido. However, I don’t use RStudio, except when I am teaching. And to be honest, it is here I find most use of Markdown. For example, in a couple of weeks I will be teaching on a module to a course on Criminology. The module I will be teaching on is about statistical methods. In the module we use R statistics. Good to know is that the students are not experienced with methods, and using R and writing codes can be overwellming. I have had this module two times now, so I know by fact that it works. But for some students it is of course hard and frustrating to write code — especially if not done that before. Which is the case for most of the students.

So one Saturday I sat down and started to learn Markdown. As I have said in previous posts I use Emacs. But in this case I actually started by using RStudio, since evertyhing is already set up. In Emacs additional packages must be installed.

One of the best features of Markdown is the possibility to use code boxes (of course also available in HTML). For example like this:

wd <- read_sav("data_file.sav")

Another very good feature (works very well when using RStudio) is the possbility to run the r code and get the output presented in the document. Markdown is also available in WordPress. Here I have used wp-markdown.

Installing Arch Linux

Arch Linux is one of the best Linux Distribution for one reason – the package manager (Pacman) and the Arch User Repository (AUR). Arch is also a good distribution if you have preferences what programs you need since you customize that by yourself. The problem for many using Arch is that the system is not intuitive to set up. There is no graphical tool – all work is done in a terminal. Of course there are installers, like Architect, and derivatives, like Manjaro.

But even though Arch Linux may not be intuitive to install it is actually not that hard of you read the Arch installation guide. There are furthermore several ways to install Arch. I have a simple way of setting up Arch Linux that you easily can do in 20-30 minutes. Why not try it in a virtual machine. Read on Arch internet site what everything do before setting it up on an actual hard drive.

$ ping -c 5

$ cfdisk

$ mkswap /dev/sda2

$ swapon /dev/sda2

$ mkfs.ext4 /dev/sda1

$ mount /dev/sda1 /mnt/

$ mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig

$ rankmirrors -n 6 /etc/pacman.d/mirrorlist.orig >/etc/pacman.d/mirrorlist

$ pacman -Syy

$ pacstrap /mnt/ base base-devel

$ cp /etc/pacman.d/mirrorlist* /mnt/etc/pacman.d

$ genfstab -p /mnt/ >> /mnt/etc/fstab

$ arch-chroot /mnt/ /bin/bash

$ pacman -S grub

$ grub-install /dev/sda

If lacking EFI – otherwise don’t do this one (i.e. if the one above works skip this one)

# grub-install –target=i386-pc –recheck /dev/sda

$ grub-mkconfig -o /boot/grub/grub.cfg

$ echo ”archlinux-desktop” > /etc/hostname

$ ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime

$ nano /etc/locale.gen


en_GB.UTF-8 UTF-8

$ locale-gen

$ echo LANG=en_GB.UTF-8 > /etc/locale.conf

$ export LANG=en_GB.UTF-8

$ passwd

$ exit

$ umount -R /mnt/

$ reboot now

$ nano /etc/vconsole.conf

add KEYMAP=atari-se

$ ping -c 5

… if not working

$ systemctl enable dhcpcd.service

$ systemctl start dhcpcd.service

$ nano /etc/pacman.conf


# [multilib]

Include = /etc/pacman.d/mirrorlist

$ pacman -Sy

$ useradd -m -g users -G wheel,storage,power,sys,adm -s /bin/bash daniel

$ passwd daniel

$ pacman -Ss sudo

$ EDITOR=nano visudo


%wheel ALL=(ALL) ALL

$ pacman -S bash-completion

$ pacman -S xorg

$ pacman -S xorg-server xorg-server-utils

$ pacman -S xorg-xinit

Install a desktop

log in as user

create /.xinitrc or copy it from /etc/x11/xinit

in /.xinitrc add

exec startxfce4

make .xinitrc executable

$ chmod +x ~/.xinitrc

install a desktop manager (slim)

$ pacman -S slim slim-themes archlinux-themes-slim xdg-user-dirs

$ systemctl enable slim.service

$ nano /etc/slim.conf

search for ’current’

change theme from default to:


# If not folders in home install xdg-user-dirs

$ sudo pacman -S xdg-user-dirs

Can you use Linux as your main work computer?

… I don’t know – but I have used Linux as my main system for more than a year now. My first computer  was a Commodore 64 which was mainly used for playing games. Back in the 1990’s, before we had Internet, my family bought an Olivetti, which had Windows. Ever since then I have used Windows. But back in 2012 I changed OS toOSX, when I bought a Macbook Pro (mid 2012). As a secondary machine I have used Linux since 2010 – mainly Ubuntu. So I have been familiar with Linux for some time now. I never had an idea to change my main system to Linux. But in the early autumn I was starting think about building a server, so I went to the store and bought some computer parts. But then the workload increased massively and there was no time to go further with the project.

In November/December that year the workload decreased some and one weekend I set up the server using Ubuntu as the operative system. During the same autumn Apple upgraded OSX from Yosemite to El Capitan, and with El Capitan Apple introduced System Integrity Protection (SIP), which prevents any user, even the root user, to modify certain files in the system. I had modified ‘certain’ files in Yosemite, especially config files related to Finder. Thus, suddenly Finder did not work as I was used to. I know that SIP can be overrided, and I did. But every time the system updated I had to override it again and do the again do the changes I wanted. So in December the main computer (by then a Macbook pro mid 2014) followed the server and I installed ubuntu, or to be more precise xubuntu, on the computer.

In spring 2016 I changed distro to Fedora, which I use today. There has mainly been no problems at all. The wifi does not work out of the box, but after installing the correct drivers that is not either an issue. As desktop I use Gnome, and after some tweaking really like it. In the picture you can see how my desktop look like.

My Desktop using Gnome

Workspaces to Dock extension.

Gnome is not that useful if you are not using extensions. So one of the first things to do is to install gnome-tweak-tool and start installing extensions. As you can see I have a lot of extensions going on my system. I have temperature and fan-speed, a to-do list extension and caffein (which can prevent your computer from going into sleep). I further have places, which list directories on the hard-drive, making it easy to quickly find what I need. I use a dock on the left and a dock up top that displays the workspaces.

Dash to Dock extension

One of the problems using a Linux system is that not to many uses Linux, especially not at work, and that a lot of the software used in Windows don’t run in Linux. Of course you can use Wine, but that is cumbersome and you miss the point by using open source/free alternatives. In my work this is most noticeable regarding the office packages. The alternative I use I LibreOffice. A lot of people say that the compatibility between Microsoft office package and LibreOffice is problematic. That is not my experience. I work with people using Microsoft Office all time. But for it to work you have to use .doc, not .docx. The only problem I have with LibreOffice is that the alternative to Powerpoint (Impress) is not good. It is almost not possible to use. Instead I use WPS. I actually have the whole WPS package just to use it for presentation. But sometimes I have also used WPS if the compatibility is bad using LibreOffice writer – which can happen if there is a lot going on in the document. For statistics I use R in Emacs (using ESS). Takes some time to get used to Emacs, but when you have it works really nice. I have Virtual Box installed and in VB I have Windows 10 installed. Some system applications that I quite seldom need to use just works in Windows.

Does Linux make me more productive? I don’t know, but the main advantage is that I can have a system of my own liking. So for me Linux works just fine. Should you use Linux as your main work computer? If you are perfectly fine with the system you use and if you are not interested in computers and technology you should probably not use Linux – not yet anyway. But if you want to try I would recommend installing Virtual Box and trying out some of the many distributions.

Hantera referenser i LibreOffice

Zotero är en av de bästa verktygen för att hantera referenser i LibreOffice. Zotero är lite, enkelt att använda och effektivt. Med Zotero kan man enkelt ladda ner referenser och pdf-filer från google scholar eller web of science, för att sedan via en knapptryckning eller via kortkommandon lägga in i dokumentet man skriver. Referenslista följs automatiskt (måste dock aktiviteras). Man kan vidare enkelt välja vilken referensstil man ska använda. Enklast är att använda APA – eftersom det går hem i princip över allt (men några små justeringar).

Zotero installerar man först och främst i sin webbrowser. Det fungerar i alla webbrowsers jag har provat, såsom Safari (om man kör OSX) och Google Chrome. Zotero är dock mer eller mindre gjort för Firefox. Man kan ha alla sina referenser i en flik i firefox – men jag skulle inte rekommendera det. Det är bättre att använda sig av standalone versionen av programmet.

Så här gör du för att installera Zotero (Ubuntu):

Öppna webb-läsaren (förslagsvis Firefox)

Surfa in på

Klicka på Download och sedan Zotero

Klicka på install

Webbläsaren kommer att starta om. Högst upp i högra hörnet i webbläsaren kan du hitta ett z. Tryck på det för att få fram dina citeringar (just nu finns det troligtvis inga där).


Screen Shot 2015-08-22 at 16.24.10


För att installera zotero standalone öppna terminalen:

sudo add-apt-repository ppa:smathot/cogscinl

sudo apt-get update

sudo apt-get install zotero-standalone

Gå till google scholar och sök något random (, t.ex. ”Are the self-employed really that poor? Income poverty and living standard among”. I webbläsaren brevid  z finns nu ytterligare en symbol (en liten rektangel). Klicka på arket, välj den referens du är intresserad av och tryck ok. Då sparas referensen ner till Zotero Standalone.

Du kan nu ladda ner dokumentet. När du gjort det, leta upp i datorn där filen laddats ner (troligtvis donwloads). Dra filen till referensen i Standalone. Då har du även artikeln i pdf-format nedladdad. Praktiskt sätt att bygga upp ett eget bibliotek. texten

Screen Shot 2015-08-22 at 16.34.03


Vid installation av Zoterostandalone installeras även tilläggen som behövs till LibreOffice. Om LibreOffice är öppet, stäng programmet och öppna igen. Nu ska det ha dykt upp ett antal symboler till vänster. Dessa använder du dig av för att lägga in referenser i texten samt lista referenserna i slutet av texten.



Microsofts typsnitt i LibreOffice (Ubuntu)

Bakgrund: Microsoft släppte sina typsnitt 1996 med genereösa licensvillkor i ett försök att sprida dessa på internet. Projektet övergavs 2002. Dessa gamla typsnitt kan dock laddas ner och användas — t.ex. Libre office. Det man behöver göra är att installera Installer for Microsoft TrueType core fonts (tff-mscorefontinstaller). I Linux mint kan man använda Software Manager för att göra detta. Tyvärr fungerar inte detta i Ubuntu. Orsaken till detta är något oklar, men det verkar ha med liscens att göra (att man måste godkänna liscensvillkoren vilket av någon anledning inte går via Software Center). Om du ändå försöker är det stor risk att Software Center fryser, alternativt att det helt enkelt meddelas att tilläggsfiler inte kunde laddas ner. Iställer måste man använda sig av terminalen.

Gör på följande sätt:

Uppdatera allt:

sudo apt-get update (kräver lösenord)

installera paketet:

sudo apt-get install ttf-mscorefonts-installer