mục lục
- Why should you use Nextcloud?
- What will you learn in this guide?
- Overview of the installation process
- Step 1: Update the system
- Step 2: Install LAMP Stack
- Step 3: Create a Database for Nextcloud
- Step 4: Download and Install Nextcloud
- Step 5: Configure Domain (Virtual Host)
- Step 6: Optimize Performance
- Step 7: Enable Free SSL (HTTPS)
- Step 8: Complete Web Setup
- Summary
- Conclusion
What is Nextcloud?
Nextcloud is one of the most powerful open-source cloud storage platforms available today. It not only allows you to store files but also includes features like calendars, contacts, video calls, and online document editing (similar to Google Workspace).
More importantly, you have full control over your data. As a result, you don’t need to rely on third-party services.
Why should you use Nextcloud?
First of all, Nextcloud is suitable for both individuals and businesses.
In addition, it offers several clear advantages:
- 🔒 Full control over your data
- ☁️ Store files, images, and videos
- 👥 Easy file sharing with your team
- 🔧 Highly customizable based on your needs
Therefore, if you are looking for a private cloud solution, Nextcloud is definitely worth trying.
What will you learn in this guide?
In this tutorial, you will go through each step in detail:
- First, install the LAMP stack on Ubuntu 24.04
- Next, configure your domain: da.datacloud.vn
- Then, create a database and install Nextcloud
- After that, optimize performance
- Finally, enable HTTPS for security
Overview of the installation process
Overall, the process includes 6 main steps:
- Update the system
- Install Apache, MariaDB, and PHP
- Create a database
- Install Nextcloud
- Configure the domain
- Optimize performance and enable SSL
Step 1: Update the system
First, update your system to avoid installation issues:
sudo apt update && sudo apt upgrade -y
Step 2: Install LAMP Stack
2.1 Install Apache
Next, install Apache:
sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2
2.2 Install MariaDB
Then, install MariaDB as your database:
sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
Next, secure your database:
sudo mysql_secure_installation
2.3 Install PHP and extensions
After that, install PHP and required extensions:
sudo apt install php libapache2-mod-php php-mysql -ysudo apt install php php-cli php-common php-mysql php-xml php-gd php-curl php-zip php-mbstring php-bz2 php-intl php-imagick php-gmp unzip -y
Then, verify the installation:
php -v
Step 3: Create a Database for Nextcloud
Now, create a database:
sudo mysql -u root -p
Run the following commands:
CREATE DATABASE da_db;
CREATE USER da_db_user@localhost IDENTIFIED BY 'da_db_PWD';
GRANT ALL PRIVILEGES ON da_db.* TO da_db_user@localhost;
FLUSH PRIVILEGES;
EXIT;
Step 4: Download and Install Nextcloud
Next, download Nextcloud:
cd /var/www/html
wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
After extracting, set the correct permissions:
sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 755 /var/www/html/nextcloud
Step 5: Configure Domain (Virtual Host)
Next, configure your domain for web access.
Create the config file:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the following content:
<VirtualHost *:80>
ServerAdmin your-email@example.com
ServerName da.datacloud.vn
DocumentRoot /var/www/html/nextcloud <Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory> ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
Then enable the configuration:
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2
👉 You can now access:
http://da.datacloud.vn
Step 6: Optimize Performance
To improve performance, update PHP settings:
sudo nano /etc/php/8.3/apache2/php.ini
Modify:
memory_limit = 512M
upload_max_filesize = 200M
post_max_size = 200M
Then restart Apache:
sudo systemctl restart apache2
Step 7: Enable Free SSL (HTTPS)
Next, enable HTTPS for better security:
sudo apt install certbot python3-certbot-apache -y
Run:
sudo certbot --apache
To auto-renew SSL, add a cron job:
crontab -e
Add:
0 3 * * * certbot renew --quiet --deploy-hook "systemctl reload apache2"
Step 8: Complete Web Setup
Finally, access:
Enter the following details:
- Username: admin
- Password: (your password)
Database:
- DB name: da_db
- User: da_db_user
- Password: da_db_PWD
Summary
At this point, you have successfully installed Nextcloud on Ubuntu 24.04. From here, you can use it to store personal data or deploy it for your team.
Additionally, to further improve performance, you can:
- Use Redis caching
- Switch to Nginx + PHP-FPM
- Set up automatic backups
Conclusion
In conclusion, Nextcloud is an excellent solution if you want to build your own private cloud. It is flexible, secure, and gives you full control over your data.
If you encounter any issues during installation, feel free to leave a comment for support 👍
Author: Lucas.V
LinkedIn: https://www.linkedin.com/in/hungntit/


Tiếng Việt