How to Install and Configure ownCloud on CentOS 9 Stream
Tags: owncloud, selfhosted, vps
Published: 2024-06-24 18:54:01

#### Prerequisites

Before starting the installation, make sure you have:
- A KVM-based NVMe VPS from [EcoStack Cloud](https://ecostack.cloud) running CentOS 9 Stream.
- A user account with sudo privileges.

#### Step 1: Update the System

Start by updating your system to ensure all packages are current.

```bash
sudo dnf update -y
```

#### Step 2: Install Required Packages

Install the necessary packages for running ownCloud. These include Apache, MariaDB, PHP, and additional modules.

```bash
sudo dnf install httpd mariadb-server mariadb php php-mysqlnd php-xml php-json php-mbstring php-gd php-curl php-intl php-zip wget unzip -y
```

#### Step 3: Start and Enable Apache and MariaDB

Enable and start the Apache and MariaDB services.

```bash
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
```

#### Step 4: Secure MariaDB Installation

Run the security script to set up a root password and secure your MariaDB installation.

```bash
sudo mysql_secure_installation
```

Follow the prompts to set the root password and remove anonymous users, disallow root login remotely, and remove the test database.

#### Step 5: Create a Database for ownCloud

Log in to MariaDB and create a database and user for ownCloud.

```bash
sudo mysql -u root -p
```

In the MariaDB shell, execute the following commands:

```sql
CREATE DATABASE owncloud;
CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON owncloud.* TO 'ownclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

Replace `your_password` with a strong password.

#### Step 6: Download and Install ownCloud

Download the latest version of ownCloud from its official website.

```bash
wget https://download.owncloud.org/community/owncloud-complete-latest.zip
```

Extract the downloaded archive and move it to the Apache web root directory.

```bash
unzip owncloud-complete-latest.zip
sudo mv owncloud /var/www/html/
```

#### Step 7: Set Permissions

Set the appropriate permissions to ensure ownCloud can read and write to its files and directories.

```bash
sudo chown -R apache:apache /var/www/html/owncloud/
sudo chmod -R 755 /var/www/html/owncloud/
```

#### Step 8: Configure Apache for ownCloud

Create a new Apache configuration file for ownCloud.

```bash
sudo nano /etc/httpd/conf.d/owncloud.conf
```

Add the following configuration:

```apache
<VirtualHost *:80>
    DocumentRoot "/var/www/html/owncloud"
    ServerName your_server_ip_or_domain

    <Directory "/var/www/html/owncloud">
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/owncloud-error_log
    CustomLog /var/log/httpd/owncloud-access_log combined
</VirtualHost>
```

Replace `your_server_ip_or_domain` with your server’s IP address or domain name. Save and close the file.

#### Step 9: Adjust Firewall Settings

Allow HTTP traffic through the firewall.

```bash
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
```

#### Step 10: Restart Apache

Restart Apache to apply the changes.

```bash
sudo systemctl restart httpd
```

#### Step 11: Complete the Installation via Web Browser

Open your web browser and navigate to `http://your_server_ip_or_domain/owncloud`. You will see the ownCloud setup page.

- Create an admin account by filling in the required details.
- Enter the database details:
  - Database user: `ownclouduser`
  - Database password: The password you set earlier
  - Database name: `owncloud`
  - Database host: `localhost`

Click "Finish Setup" to complete the installation.

---

### Conclusion

You have successfully installed and configured ownCloud on CentOS 9 Stream with [EcoStack Cloud](https://ecostack.cloud). You can now use your own cloud storage solution to manage and share your files securely.

For more details and advanced configurations, check out the [official ownCloud documentation](https://doc.owncloud.com/server/admin_manual/).