How to Install Nextcloud on Linux Using apt/yum

Nextcloud is a popular self-hosted file sharing and collaboration platform. Here is a step-by-step guide on how to install Nextcloud on your Linux server using apt or yum package managers:

1. Install the LAMP stack:
sudo apt install lamp-server^
sudo yum install httpd mariadb-server php php-mysqlnd php-xml php-json php-gd php-mbstring

2. Enable and start the Apache and MariaDB services:
sudo systemctl enable --now apache2
sudo systemctl enable --now mariadb

3. Secure the MariaDB installation:
sudo mysql_secure_installation

4. Create a new MariaDB database and user:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

5. Download and install the latest version of Nextcloud:
wget https://download.nextcloud.com/server/releases/nextcloud-24.0.2.zip
sudo apt install unzip
unzip nextcloud-24.0.2.zip -d /var/www/html/
sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/

6. Open the Nextcloud installation page in your web browser and follow the on-screen instructions to set up the admin account and configure your instance.

That's it! Now you can start using Nextcloud on your Linux server.