Here is a detailed guide to installing Nextcloud with PHP 8.3 on a Linux server, using Ubuntu Server and MariaDB as the database.
Start by updating your system:
sudo apt update && sudo apt upgrade -y
To run Nextcloud, you need PHP 8.3 and several extensions:
First, add the `ppa:ondrej/php` repository to get PHP 8.3:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Install PHP 8.3 and the necessary extensions:
sudo apt install Apache libapache2-mod-php8.3 -y
sudo apt install php8.3 php8.3-gd php8.3-mysql php8.3-curl php8.3-mbstring php8.3-intl php8.3-imagick php8.3-xml php8.3-zip php8.3-bz2 php8.3-apcu -y
Each of these PHP extensions is required for different Nextcloud functionalities:
- `php8.3-gd`: Image processing library.
- `php8.3-mysql`: MySQL/MariaDB connection.
- `php8.3-curl`: URL transfer library.
- `php8.3-mbstring`: Multi-byte string handling.
- `php8.3-intl`: Internationalization functions.
- `php8.3-imagick`: Image processing.
- `php8.3-xml`: XML processing.
- `php8.3-zip`: ZIP archiving.
- `php8.3-bz2`: Bzip2 compression support.
- `php8.3-apcu`: APCu caching support.
Check that PHP 8.3 was installed correctly:
php -v
Install MariaDB:
sudo apt install mariadb-server -y
Secure the MariaDB installation:
sudo mysql_secure_installation
This wizard helps you set the root password, remove anonymous users, disable remote root login, and delete the test database.
Log into MariaDB and create a database and user for Nextcloud:
sudo mysql -u root -p
Run the following SQL commands:
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'your_password';
Replace `your_password` with a strong password.
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download and unzip the latest Nextcloud release:
wget https://download.nextcloud.com/server/releases/nextcloud-29.0.5.zip
unzip nextcloud-29.0.5.zip
sudo mv nextcloud /var/www/
Set the appropriate permissions for Apache to access the Nextcloud files:
sudo chown -R www-data:www-data /var/www/nextcloud/
sudo chmod -R 755 /var/www/nextcloud/
To run Nextcloud on Apache, create a configuration file:
Create a new virtual host file for Nextcloud:
sudo nano /etc/Apache/sites-available/nextcloud.conf
Paste the following content:
<VirtualHost *:80>
DocumentRoot /var/www/nextcloud/
ServerName your-domain.com
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
Enable the necessary Apache modules:
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
Restart Apache:
sudo systemctl restart Apache
For security, enable HTTPS using an SSL certificate from Let's Encrypt or another provider.
You can install a free SSL certificate from Let's Encrypt:
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache
Open your web browser and navigate to `http://your-domain.com`. The Nextcloud setup wizard should appear.
- **Database user**: `nextclouduser`
- **Database password**: `your_password`
- **Database name**: `nextcloud`
- **Database host**: `localhost`
Complete the setup to start using Nextcloud.
You can take some additional steps to secure your Nextcloud installation and improve performance:
Review the security settings recommended by Nextcloud:
To enhance the performance of Nextcloud, follow these steps:
sudo apt install redis-server php8.3-redis -y
Edit the `config.php` file to add Redis to Nextcloud:
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => 'localhost',
'port' => 6379,
],
Set up a cron job to ensure that Nextcloud performs maintenance tasks on time:
sudo crontab -u www-data -e
Add the following line:
*/5 * * * * php -f /var/www/nextcloud/cron.php
Following these steps, you will have a fully functional Nextcloud instance running with PHP 8.3.