This Guide assumes that you are starting from CentOS 7 R1611 Minimal.
Install CentOS 7 and then either log in as root, su to root, or prepend everything here with sudo. Your choice.
#Update centos
yum update -y
#install helper packages
yum install -y wget nano yum-utils
#install EPEL
yum install -y epel-release
#install Remi
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
#enable PHP 7.1 by editing the repo file and changing enabled=0 to 1
yum-config-manager --enable remi-php71
Now install all of the packages that will be needed by NextCloud
#Install all required and optional packages
yum -y install httpd mariadb mariadb-server php php-gd php-pdo php-pear php-mbstring php-xml php-pear-Net-Curl php-mcrypt php-intl php-ldap php-smbclient php-imap php-mysql php-pear-MDB2 php-pear-MDB2-Driver-mysqli php-pecl-zip bzip2 policycoreutils-python redis php-pecl-redis
Install NextCloud 11.0.2. Update the wget
and tar
command 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-11.0.2.tar.bz2
#Extract NextCloud
tar xvf nextcloud-11.0.2.tar.bz2 -C /var/www/html
#Create directories not created by extract
mkdir -p /var/www/html/nextcloud/data
#get the nextcloud apache config file
# the current file is currently broken for this guide, use the original commit version below.
#wget -O /etc/httpd/conf.d/nextcloud.conf https://raw.githubusercontent.com/nextcloud/server-packages/master/centos/nextcloud.conf
wget -O /etc/httpd/conf.d/nextcloud.conf https://raw.githubusercontent.com/nextcloud/server-packages/18f3837752589739b53bc62705c45a54faddbb4a/centos/nextcloud.conf
Now set up proper ownership and permissions to the files.
#default everything to root:apache
chown -R root:apache /var/www/html/nextcloud/.
#set default directory and file permissions
find /var/www/html/nextcloud -type d -exec chmod 0750 {} \;
find /var/www/html/nextcloud -type f -exec chmod 0640 {} \;
#change ownership of folders and files
chmod 0755 /var/www/html/nextcloud
chmod 0755 /var/www/html/nextcloud/occ
chown apache:apache /var/www/html/nextcloud/occ
chmod 0644 /var/www/html/nextcloud/.htaccess
chown apache:apache /var/www/html/nextcloud/.htaccess
find /var/www/html/nextcloud/apps -exec chmod 0750 {} \;
chown -R apache:apache /var/www/html/nextcloud/apps
find /var/www/html/nextcloud/updater -exec chmod 0750 {} \;
chown -R apache:apache /var/www/html/nextcloud/updater
find /var/www/html/nextcloud/data -exec chmod 0755 {} \;
chown -R apache:apache /var/www/html/nextcloud/data
find /var/www/html/nextcloud/config -exec chmod 0755 {} \;
chown -R apache:apache /var/www/html/nextcloud/config
Open the firewall and start the database services.
#open the firewall for http
firewall-cmd --zone=public --add-port=http/tcp --permanent
firewall-cmd --reload
#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;"
Tell SELinux that we want to send email and that the data
, config
, and apps
folders need to be writable by the webserver.
#tell SELinux to allow apache to send smtp and network connect
setsebool -P httpd_can_sendmail 1
setsebool -P httpd_can_network_connect 1
#change SELinux permissions for directories that need apache write access.
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?'
restorecon -R /var/www/html/nextcloud/config
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?'
restorecon -R /var/www/html/nextcloud/apps
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?'
restorecon -R /var/www/html/nextcloud/data
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/updater(/.*)?'
restorecon -R /var/www/html/nextcloud/updater
Restart the webserver
#Restart Apache and enable for reboot.
systemctl restart httpd
systemctl enable httpd
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 yout config.php later anyway.
#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.
Then click the Storage & database dropdown.
Leave the data folder alone unless you know that you changed it when going through the above instructions.
Change the database to MySQL/MariaDB
Then fill it out with the information you used above.
Click the Finish setup button
You will be automatically logged in and greeted with this.
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.