Install Nextcloud 13.0.0 on Fedora 27



  • This Guide assumes that you are starting from Fedora 27 Minimal.

    Install Fedora 27 and then either log in as root, su to root, or prepend everything here with sudo. Your choice.

    #Update Fedora
    dnf update -y
    
    #install Nextcloud required and optional packages
    #wget is required because the Nexcloud guide says to use wget.
    #policycoreutils-python-utils is required to run semanage
    dnf install -y httpd mariadb mariadb-server php php-gd php-pdo php-pear php-mbstring php-xml php-pear-Net-Curl php-json php-mcrypt php-intl php-ldap php-smbclient php-imap php-mysqli php-pear-MDB2 php-pear-MDB2-Driver-mysqli php-pecl-zip bzip2 policycoreutils-python-utils redis php-pecl-redis wget php-opcache libreoffice certbot python2-certbot-apache mod_ssl tar
    
    
    #Install nano because I do not want to use `vi`
    dnf install -y nano
    

    Install NextCloud 13.0.0. Update the wget and tar commands to reflect the current version at the time of your installation.

    #Create the root directory to extract nextcloud to
    mkdir -p /var/www/html/nextcloud
    
    #Get NextCloud
    wget https://download.nextcloud.com/server/releases/nextcloud-13.0.0.tar.bz2
    
    #Extract NextCloud
    tar xvf nextcloud-13.0.0.tar.bz2 -C /var/www/html
    

    Now we need to create the data directory. By default, Nextcloud will expect it to be within the main directory. If you move it, you will have to update a few things below to reference to correct folder path.

    Personally, if you are going to use a separate disk for the data, I would just mount it to /var/www/html/nextcloud/data

    So create the data directory

    #Create the data directory 
    mkdir -p /var/www/html/nextcloud/data
    

    Now grab the apache vhost file

    #get the nextcloud apache config file
    wget -O /etc/httpd/conf.d/nextcloud.conf https://raw.githubusercontent.com/sorvani/scripts/master/Nextcloud/nextcloud.conf
    

    Then set ownership of all the files to apache

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

    Open up the firewall to http traffic

    #open the firewall for http
    firewall-cmd --add-port=http/tcp --permanent
    firewall-cmd --add-port=https/tcp --permanent
    firewall-cmd --reload
    

    Start the database services

    
    #start the mariadb and set to start on boot
    systemctl start mariadb
    systemctl enable mariadb
    
    #start redis (used for memcache)
    systemctl start redis
    systemctl enable redis
    

    Create the Nextcloud database and then secure the mariadb install.

    Change ncuser, ncuserpassword, and somesecurepassword to something private.

    #Create a database for nextcloud and a user to access it.
    mysql -e "CREATE DATABASE nextcloud;"
    mysql -e "CREATE USER 'ncuser'@'localhost' IDENTIFIED BY 'ncuserpassword';"
    mysql -e "GRANT ALL ON nextcloud.* TO 'ncuser'@'localhost';"
    mysql -e "FLUSH PRIVILEGES;"
    
    #Secure mariadb. These commands do what mysql_secure_installation does interactively
    mysql -e "UPDATE mysql.user SET Password=PASSWORD('somesecurepassword') WHERE User='root';"
    mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
    mysql -e "DELETE FROM mysql.user WHERE User='';"
    mysql -e "DROP DATABASE test;"
    mysql -e "FLUSH PRIVILEGES;"
    

    Configure SELinux permissions to allow email, network connections, and read/write permissions to the necessary folders.

    #download the script 
    wget -O ~/selinux_config.sh https://raw.githubusercontent.com/sorvani/scripts/master/Nextcloud/selinux_config.sh
    #set it to executable
    chmod +x ~/selinux_config.sh
    #execute the script
    ~/selinux_config.sh
    

    Start the webserver

    #Start Apache and enable for reboot.
    systemctl restart httpd
    systemctl enable httpd
    

    Update the php-opcache ini file

    sed -i -e 's/;opcache.enable_cli=0/opcache.enable_cli=1/' /etc/php.d/10-opcache.ini;
    sed -i -e 's/opcache.max_accelerated_files=4000/opcache.max_accelerated_files=10000/' /etc/php.d/10-opcache.ini;
    sed -i -e 's/;opcache.save_comments=1/opcache.save_comments=1/' /etc/php.d/10-opcache.ini;
    sed -i -e 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=1/' /etc/php.d/10-opcache.ini;
    

    Restart the php-fpm to apply the opcahce settings

    systemctl restart php-fpm
    

    Creating a DNS entry is optional, but when the Nextcloud first run wizard happens in the browser, it sets the config.php to trust the URL in the browser. If you do not have DNS setup yet, you will have to go back and add this to your config.php later.

    #create a DNS entry for your server and go to it in your browser to complete the setup
    http://nextcloud.domain.com/nextcloud
    

    On the web GUI, enter your desired admin username and password.
    0_1489694134750_upload-6982fc23-f37f-40b8-8555-02ea1d6737be

    Then click the Storage & database dropdown.
    0_1489694170160_upload-db1dd473-e6ba-47d0-bed0-630e5efed8e7

    Leave the data folder alone unless you know that you changed it when going through the above instructions.
    0_1489694494762_upload-54c0e57e-4f3d-402d-a4d5-5f64d4a28bf0

    Change the database to MySQL/MariaDB
    0_1489694525338_upload-09b6afa0-19f8-4661-b8f8-30f3bfc05068

    Then fill it out with the information you used above.
    0_1489694596256_upload-c7100936-4fff-4a6f-a4c2-1968cc60ce35

    Click the Finish setup button
    0_1489694613615_upload-0e8c9b25-0269-40b1-8d03-b30523f06f01

    You will be automatically logged in and greeted with this.
    0_1489694685297_upload-cdf842b9-179e-4f3e-84e0-a93c3c64c5bb

    Go back to your SSH session and update the NextCloud config.php file to tell it to use redis for the memory cache and file locking.

    #add a line to nextcloud config.php to enable memory cache
    nano /var/www/html/nextcloud/config/config.php
    'memcache.locking' => '\OC\Memcache\Redis',
    'memcache.local' => '\OC\Memcache\Redis',
        'redis' => array(
        'host' => 'localhost',
        'port' => 6379,
    ),
    

    Restart the webserver

    systemctl restart httpd
    

    You now have a fully configured basic install.



  • Wow, who would have guessed that installing on Linux would be so easy?



  • I was literally doing an NC13 on Fedora 27 install while you posted this, following this now.



  • I'll update some other issues on this later. Such as clearing up opchache warnings and such.



  • Wow, who would have thought it would be so easy to install NextCloud on Linux doing it the correct and supported way, as your guide shows!



  • Super easy, install worked without a hitch.



  • Don't forget to add this bit, to clear the opcache warning...

    # php-opcache
    sudo dnf -y install php-opcache
    
    # /etc/php.d/10-opcache.ini
    sudo tee  /etc/php.d/10-opcache.ini <<EOF
    opcache.enable=1
    opcache.enable_cli=1
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq=1
    EOF
    
    # Restart php-fpm
    sudo systemctl restart php-fpm
    


  • Also, for those of us using the stock Fedora 27 Server install, the default firewall zone is FedoraServer, rather than public, so this is the command that I use for the firewall...

    firewall-cmd --zone=FedoraServer --add-port=https/tcp --permanent


  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Don't forget to add this bit, to clear the opcache warning...

    # php-opcache
    sudo dnf -y install php-opcache
    
    # /etc/php.d/10-opcache.ini
    sudo tee  /etc/php.d/10-opcache.ini <<EOF
    opcache.enable=1
    opcache.enable_cli=1
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq=1
    EOF
    
    # Restart php-fpm
    sudo systemctl restart php-fpm
    

    Yeah I ran out of time. Was time to go be with the kids for a while.



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Also, for those of us using the stock Fedora 27 Server install, the default firewall zone is FedoraServer, rather than public, so this is the command that I use for the firewall...

    firewall-cmd --zone=FedoraServer --add-port=https/tcp --permanent
    

    Eww minimal install always.



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Don't forget to add this bit, to clear the opcache warning...

    # php-opcache
    sudo dnf -y install php-opcache
    
    # /etc/php.d/10-opcache.ini
    sudo tee  /etc/php.d/10-opcache.ini <<EOF
    opcache.enable=1
    opcache.enable_cli=1
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq=1
    EOF
    
    # Restart php-fpm
    sudo systemctl restart php-fpm
    

    This is a horrible solution.

    WHen you install php-opcache, it creates a 10-opcache.ini with half of these settigns as defualt.

    Additionally this nukes all other settings int he default config file.



  • I am updating the above instructions to include these settings, but here it is by itself.

    #install php-opcache
    dnf  -y install php-opcache
    
    #update the settings file.
    sed -i -e 's/;opcache.enable_cli=0/opcache.enable_cli=1/' /etc/php.d/10-opcache.ini;
    sed -i -e 's/opcache.max_accelerated_files=4000/opcache.max_accelerated_files=10000/' /etc/php.d/10-opcache.ini;
    sed -i -e 's/;opcache.save_comments=1/opcache.save_comments=1/' /etc/php.d/10-opcache.ini;
    sed -i -e 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=1/' /etc/php.d/10-opcache.ini;
    
    #restart the service
    systemctl restart php-fpm
    


  • There we go.

    If you follow these instructions you should see this in the admin settings.

    0_1518230761453_08b85b94-ad7a-44d7-aa83-87efed3da3e2-image.png



  • Followed these instructions and installed without a hitch! Already have Nextcloud running but it's on Ubuntu. Wanted to give it a try on Fedora. Thanks for this.



  • @nashbrydges said in Install Nextcloud 13.0.0 on Fedora 27:

    Followed these instructions and installed without a hitch! Already have Nextcloud running but it's on Ubuntu. Wanted to give it a try on Fedora. Thanks for this.

    I'm REALLY close to having this fully scripted with interactivity on the script 🙂



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    @nashbrydges said in Install Nextcloud 13.0.0 on Fedora 27:

    Followed these instructions and installed without a hitch! Already have Nextcloud running but it's on Ubuntu. Wanted to give it a try on Fedora. Thanks for this.

    I'm REALLY close to having this fully scripted with interactivity on the script 🙂

    Shall I turn it into a Salt State or is that what you are working on already?



  • @tim_g said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    @nashbrydges said in Install Nextcloud 13.0.0 on Fedora 27:

    Followed these instructions and installed without a hitch! Already have Nextcloud running but it's on Ubuntu. Wanted to give it a try on Fedora. Thanks for this.

    I'm REALLY close to having this fully scripted with interactivity on the script 🙂

    Shall I turn it into a Salt State or is that what you are working on already?

    We've had that for a while 😉



  • @tim_g said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    @nashbrydges said in Install Nextcloud 13.0.0 on Fedora 27:

    Followed these instructions and installed without a hitch! Already have Nextcloud running but it's on Ubuntu. Wanted to give it a try on Fedora. Thanks for this.

    I'm REALLY close to having this fully scripted with interactivity on the script 🙂

    Shall I turn it into a Salt State or is that what you are working on already?

    https://mangolassi.it/topic/12869/install-nextcloud-11-on-fedora-25-with-saltstack



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    I'm REALLY close to having this fully scripted with interactivity on the script 🙂

    What will be different or better about this method vs SaltStack method?



  • @fateknollogee said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    I'm REALLY close to having this fully scripted with interactivity on the script 🙂

    What will be different or better about this method vs SaltStack method?

    A script is a procedural approach and Salt is a state approach. Results upon completion are the same, but they are different methodologies and are used in different scenarios.

    Scripting a build is better for learning and is used to make a repeatable, predictable start to a snowflake managed system.

    A state system, like Salt or Ansible, is used to define the resulting state of a system rather than the means to make it so and is not nearly as useful for learning, but is part of ongoing operations rather than simply being the beginning of the process. A Salt state would be used to keep managing the system, not just a one time operation to prepare it.



  • Testing the script now....



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Scripting a build is better for learning

    I've seen your scripts. they are totally not for learning a damned thing.

    That is why I specifically never post instructions like this in a script form.



  • @jaredbusch said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Scripting a build is better for learning

    I've seen your scripts. they are totally not for learning a damned thing.

    That is why I specifically never post instructions like this in a script form.

    What? How are bash scripts not for learning?

    I learn so much more going over scripts than I would any other way. The more efficient they are written, the more I learn.



  • @tim_g said in Install Nextcloud 13.0.0 on Fedora 27:

    @jaredbusch said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Scripting a build is better for learning

    I've seen your scripts. they are totally not for learning a damned thing.

    That is why I specifically never post instructions like this in a script form.

    What? How are bash scripts not for learning?

    I learn so much more going over scripts than I would any other way. The more efficient they are written, the more I learn.

    Did you look at his thread? there is no learning. it is "run this"

    That is always how he writes them up.

    There is zero wrong with that approach. It is in fact a better way to do it if you just want to tell someone go here and do this and it will work.

    But that is not what I write my guide to do. My guides are guides that you perform everything step by step.



  • @jaredbusch said in Install Nextcloud 13.0.0 on Fedora 27:

    @tim_g said in Install Nextcloud 13.0.0 on Fedora 27:

    @jaredbusch said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Scripting a build is better for learning

    I've seen your scripts. they are totally not for learning a damned thing.

    That is why I specifically never post instructions like this in a script form.

    What? How are bash scripts not for learning?

    I learn so much more going over scripts than I would any other way. The more efficient they are written, the more I learn.

    Did you look at his thread? there is no learning. it is "run this"

    That is always how he writes them up.

    There is zero wrong with that approach. It is in fact a better way to do it if you just want to tell someone go here and do this and it will work.

    But that is not what I write my guide to do. My guides are guides that you perform everything step by step.

    Oh I see what you mean. I agree.

    But...
    I think Scott meant writing a script or reading a script is great for learning, I don't think he meant copy and pasting a line that is fully automated.



  • @jaredbusch said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Scripting a build is better for learning

    I've seen your scripts. they are totally not for learning a damned thing.

    That is why I specifically never post instructions like this in a script form.

    Writing a script is more for learning than writing a state is. Because a state might work without any info or interaction from you.



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    @jaredbusch said in Install Nextcloud 13.0.0 on Fedora 27:

    @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Scripting a build is better for learning

    I've seen your scripts. they are totally not for learning a damned thing.

    That is why I specifically never post instructions like this in a script form.

    Writing a script is more for learning than writing a state is. Because a state might work without any info or interaction from you.

    Okay, that makes more sense.



  • I have a Nextcloud instance running on Hyper-V using a 500GB dynamically expanding disk that is working perfectly. I can see that it's barely using any of the space. I followed these instructions for creating a Nextcloud instance on Fedora and when I use a dynamically expanding disk, for some reason, the install does not recognize it as a full 500GB disk so after uploading a few large test files, I'm out of space at around 10GB. The Nextcloud instance is on a Fedora 27 minimal install.

    Any ideas where I may have gone wrong? I used this command to create the disk:

    New-VHD -Path C:\MyVHDs\nextcloud.vhdx -SizeBytes 500GB -Dynamic -BlockSizeBytes 1MB

    Does Fedora not play well with dynamically expanding disks? I could instead create a fixed disk but I'd like to avoid that if I can.



  • @nashbrydges said in Install Nextcloud 13.0.0 on Fedora 27:

    I have a Nextcloud instance running on Hyper-V using a 500GB dynamically expanding disk that is working perfectly. I can see that it's barely using any of the space. I followed these instructions for creating a Nextcloud instance on Fedora and when I use a dynamically expanding disk, for some reason, the install does not recognize it as a full 500GB disk so after uploading a few large test files, I'm out of space at around 10GB. The Nextcloud instance is on a Fedora 27 minimal install.

    Any ideas where I may have gone wrong? I used this command to create the disk:

    New-VHD -Path C:\MyVHDs\nextcloud.vhdx -SizeBytes 500GB -Dynamic -BlockSizeBytes 1MB

    Does Fedora not play well with dynamically expanding disks? I could instead create a fixed disk but I'd like to avoid that if I can.

    Haven't tried that, but I would not expect it to like that.



  • @scottalanmiller said in Install Nextcloud 13.0.0 on Fedora 27:

    Haven't tried that, but I would not expect it to like that.

    So you're suggesting I'd stick to fixed disk instead? Curious as to why Ubuntu seems ok with it but Fedora isn't.