frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

[NextCloud] NextCloud 12.0 installation with MariaDB and PHP 7.2

ValentineValentine Member
edited September 25 in Web Applications

NextCloud puts your data at your fingertips, under your control. You store your photos, calendar, contacts, and documents on a server of your choosing be it at home, a rented server or at one of our providers. Your existing data can stay at that FTP drive at work, Dropbox or a NAS you have at home, while you get at it through NextCloud.

A trusted solution giving you access to all the data you care about in one convenient place!

The tutorial was prepared with our "CentOS 7" template and is meant to work on our self-managed virtual private servers.

WARNING

CentOS 7 reached the EOL June 30, 2024:

https://blog.centos.org/2023/04/end-dates-are-coming-for-centos-stream-8-and-centos-linux-7/

Because of this, you may encounter some repository issues. We recommend that you reinstall another OS that has not yet reached EOL.

If you are using CentOS 7 and encounter a mirror issue, please check out this guide to resolve the problem.

0. Preliminary requirements:
"CentOS 7" template installed on the server;
Dependencies required for installation steps:
yum install -y epel-release yum-utils unzip curl wget bash-completion policycoreutils-python mlocate bzip2 nano
Fully updates server software (yum update);
1. MariaDB installation
yum install -y mariadb mariadb-server
Enable MariaDB to automatically start after server reboot:
systemctl enable mariadb.service
Start MariaDB:
systemctl start mariadbNow run the post-installation security script:
mysql_secure_installation
When the script asks you to enter MariaDB root password, press enter because you have not set the root password yet. Then enter "Y" to set the root password for the MariaDB server. And proceed with pressing Enter to answer all the remaining questions.

2. Apache and PHP 7 installation
Apache installation:
yum install -y httpd
Start Apache:
systemctl enable httpd.service
systemctl start httpd.service
This installation will be of only the necessary PHP modules. For more complete install, other PHP modules might be required too.  At the moment, proceed with the following installation:
yum install -y centos-release-scl
yum install -y rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring \ rh-php72-php-intl rh-php72-php-pecl-apcu rh-php72-php-mysqlnd rh-php72-php-pecl-redis \ rh-php72-php-opcache rh-php72-php-imagick
Create the required symlinks:
ln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/
ln -s /opt/rh/rh-php72/root/bin/php /usr/bin/php
Restart Apache to load the new version of PHP:
systemctl restart httpd

3. Creating a MariaDB database and user
Login to your MariaDB:
mysql -u root -p
Create a database:
CREATE DATABASE nextcloud;
Create user:
CREATE USER nextclouduser@localhost IDENTIFIED BY 'your-password';
Grant privileges for user and exit:
GRANT ALL PRIVILEGES ON nextcloud.* to nextclouduser@localhost IDENTIFIED BY 'your-password';

FLUSH PRIVILEGES;

exit;

4. Enable Binary Logging in MariaDB
Open MySQL my.cnf configuration file for edit:
nano /etc/my.cnf
Add the following three lines in the [mysqld] section:
log-basename=master
log-bin
binlog-format=mixed
Restart MariaDB:
systemctl restart mariadb

5. Download NextCloud files:
Download latest NextCloud package:
wget https://download.nextcloud.com/server/releases/nextcloud-18.0.3.zip
The latest release can be found at: https://nextcloud.com/install/#instructions-server

Extract it:
unzip nextcloud-18.0.3.zip
Move files to your Apache directory:
mv nextcloud/* nextcloud/.* /var/www/html/
6. Setting strong directory permissions
Create "permissions.sh" file:
nano permissions.sh
Insert the content:
#!/bin/bash
ncpath='/var/www/html/'
htuser='apache'
htgroup='apache'
rootuser='root'

printf "Creating possible missing Directories\n"
mkdir -p $ncpath/data
mkdir -p $ncpath/assets
mkdir -p $ncpath/updater

printf "chmod Files and Directories\n"
find ${ncpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ncpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ncpath}/
chown -R ${htuser}:${htgroup} ${ncpath}/apps/
chown -R ${htuser}:${htgroup} ${ncpath}/assets/
chown -R ${htuser}:${htgroup} ${ncpath}/config/
chown -R ${htuser}:${htgroup} ${ncpath}/data/
chown -R ${htuser}:${htgroup} ${ncpath}/themes/
chown -R ${htuser}:${htgroup} ${ncpath}/updater/

chmod +x ${ncpath}/occ

printf "chmod/chown .htaccess\n"
if [ -f ${ncpath}/.htaccess ]
then
chmod 0644 ${ncpath}/.htaccess
chown ${rootuser}:${htgroup} ${ncpath}/.htaccess
fi
if [ -f ${ncpath}/data/.htaccess ]
then
chmod 0644 ${ncpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ncpath}/data/.htaccess
fi
Run the file:
bash permissions.sh

7. NextCloud installation
Open your server hostname or IP address in the browser and finish the installation.



More information about NextCloud project can be found at: https://nextcloud.com/

Comments

  • Hi
    Are you sure with Step 5? (mv nextcloud/* nextcloud/.* /var/www/html/)
    I get the following:


    [root@ih0 ~]# mv nextcloud/* nextcloud/.* /var/www/html/
    mv: overwrite '/var/www/html/.'? Y
    mv: cannot move 'nextcloud/.' to '/var/www/html/.': Device or resource busy


    May you can look at this issue? That would be great. I made excactly what you wrote. (Otherwise a very good instruction. Thank you very much!!)
    Andy
  • That is my structure:
    root@ih0 ~]# ls -a
    . .. .bash_logout .bash_profile .bashrc .cshrc .mysql_history .pki .tcshrc nextcloud nextcloud-9.0.53.zip setup-ius.sh
    [root@ih0 ~]#
  • Maybe mv nextcloud/{.,}* /var/www/html/ is better?
  • When prompted with a line:
    mv: overwrite '/var/www/html/.'?
    And:
    mv: overwrite '/var/www/html/..'?
    Just press "Enter" do not write "Y" or "y".

    There can be another ways to move everything from "nextcloud" folder to "html" folder.
  • Thank's Valentine. Great!
  • These instructions are ancient by now, and the custom installation of PHP 7.0 from this article is obsolete now. A colleague of mine used the instructions, however, and now it's causing conflicts when I want to install NextCloud through yum.

    I'm not too familiar with CentOS, so I don't know how to remove the repository that offers the obsolete PHP 7.0. Could anyone help?
  • ValentineValentine Member
    edited August 2017
    DaVince said:
    These instructions are ancient by now, and the custom installation of PHP 7.0 from this article is obsolete now. A colleague of mine used the instructions, however, and now it's causing conflicts when I want to install NextCloud through yum.

    I'm not too familiar with CentOS, so I don't know how to remove the repository that offers the obsolete PHP 7.0. Could anyone help?
    You can't follow two or more instructions on the same thing if you are not sure what you're doing. In our instructions there is no NextCloud installation through yum and that is why you get an error.

    We will update this instruction in future with PHP 7.1 and NextCloud 12 version.

    Regarding repository you can simply disable it by opening its file in /etc/yum.repos.d/ and replacing:
    enabled=1

    to

    enabled=0


  • Hi,
    I had to
    yum install sudo
    before I could start with step 2 that installs PHP.

  • GiedriusGiedrius Guest
    edited September 2018
    Hello @matjazv,

    Current OS templates are minimal, it doesn't include "sudo" option so it needs to be installed.

    However, if you are working as "root" user, the sudo isn't needed and you could run commands like this:
    pm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    Anyway, I have edited the article, glad you found a solution fast. :)
  • Hi @Giedrius, thanks!
    The next stump for me was at
    systemctl restart httpd
    because the template does not have an Apache yet. So I did
    yum install httpd
    sudo systemctl enable httpd.service
    sudo systemctl restart httpd.service
    which now allows me to do
    systemctl restart httpd
    Do I need to tweak anything else in Apache to adapt it to the local structure and/or keep it secure?
    best
    m





  • actually, there shouldn't be anything else that would need to be added to config additionally. Since previously Apache was pre-installed within our OS template, it had only basic config, nothing unusual.
    So after your manual installation Apache should have the same basic config.
Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch