sudo dnf update -y sudo dnf install epel-release -y
sudo dnf install httpd -y sudo systemctl enable --now httpd
sudo dnf install mariadb-server -y sudo systemctl enable --now mariadb
sudo mysql_secure_installationSet the root password and remove insecure defaults.
sudo dnf install expect -y mkdir -p /root/scripts cat << 'EOF' > /root/scripts/secure_mysql.expect #!/usr/bin/expect -f set timeout 10 spawn mysql_secure_installation expect "Enter password for user root:" { send "\r" } expect "Switch to unix_socket authentication" { send "n\r" } expect "Change the root password?" { send "n\r" } expect "Remove anonymous users?" { send "y\r" } expect "Disallow root login remotely?" { send "y\r" } expect "Remove test database and access to it?" { send "y\r" } expect "Reload privilege tables now?" { send "y\r" } expect eof EOF chmod +x /root/scripts/secure_mysql.expect /root/scripts/secure_mysql.expect
sudo dnf module reset php -y sudo dnf module enable php:8.2 -y sudo dnf install php php-mysqlnd php-gd php-xml php-mbstring php-curl php-zip php-cli php-bcmath php-intl php-json php-common php-opcache -y sudo systemctl restart httpd php -v
sudo mysql -u root -p
CREATE DATABASE nextcloud; CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'StrongPassword123'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost'; FLUSH PRIVILEGES; EXIT;
cd /var/www/ sudo curl -O https://download.nextcloud.com/server/releases/nextcloud-31.0.4.zip sudo unzip nextcloud-31.0.4.zip sudo chown -R apache:apache nextcloud
sudo nano /etc/httpd/conf.d/nextcloud.conf
<VirtualHost *:80> ServerName yourdomain.com DocumentRoot /var/www/nextcloud/ <Directory /var/www/html/nextcloud/> Require all granted AllowOverride All Options FollowSymLinks MultiViews </Directory> ErrorLog /var/log/httpd/nextcloud_error.log CustomLog /var/log/httpd/nextcloud_access.log combined </VirtualHost>
sudo systemctl restart httpd
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reloadIf firewall is not installed:
sudo dnf install firewalld -y sudo systemctl start firewalld sudo systemctl enable firewalld
sudo dnf install certbot python3-certbot-apache -y sudo certbot --apache -d yourdomain.com
http://yourdomain.com
http://your-server-ip/nextcloud
sudo dnf update -y sudo dnf install epel-release -y sudo dnf install httpd -y sudo systemctl enable --now httpd sudo dnf install mariadb-server -y sudo systemctl enable --now mariadb sudo dnf install expect -y mkdir -p /root/scripts cat << 'EOF' > /root/scripts/secure_mysql.expect #!/usr/bin/expect -f set timeout 10 spawn mysql_secure_installation expect "Enter password for user root:" { send "\r" } expect "Switch to unix_socket authentication" { send "n\r" } expect "Change the root password?" { send "n\r" } expect "Remove anonymous users?" { send "y\r" } expect "Disallow root login remotely?" { send "y\r" } expect "Remove test database and access to it?" { send "y\r" } expect "Reload privilege tables now?" { send "y\r" } expect eof EOF chmod +x /root/scripts/secure_mysql.expect /root/scripts/secure_mysql.expect sudo mysql -u root -p CREATE DATABASE nextcloud; CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'StrongPassword123'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost'; FLUSH PRIVILEGES; EXIT; sudo dnf module reset php -y sudo dnf module enable php:8.2 -y sudo dnf install php php-mysqlnd php-gd php-xml php-mbstring php-curl php-zip php-cli php-bcmath php-intl php-json php-common php-opcache -y cd /var/www/ sudo curl -O https://download.nextcloud.com/server/releases/nextcloud-31.0.4.zip sudo unzip nextcloud-31.0.4.zip sudo chown -R apache:apache nextcloud sudo tee /etc/httpd/conf.d/nextcloud.conf > /dev/null < ServerName yourdomain.com DocumentRoot /var/www/nextcloud/ Require all granted AllowOverride All Options FollowSymLinks MultiViews ErrorLog /var/log/httpd/nextcloud_error.log CustomLog /var/log/httpd/nextcloud_access.log combined EOF sudo dnf install firewalld -y sudo systemctl start firewalld sudo systemctl enable firewalld sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload sudo systemctl restart httpd