Introduction
In this article, I have collected different troubleshooting techniques for self-hosted Nextcloud installation on Ubuntu 22.04 Server. I had the most problems due to the PHP version. In this guide, we will dive into troubleshooting common PHP-related issues in Nextcloud,
Solving Common PHP Issues on Ubuntu 22.04
As a powerful self-hosted cloud solution, Nextcloud relies heavily on PHP for its server-side operations. Problems with PHP configurations, memory limits, and module compatibility can disrupt the smooth running of your Nextcloud instance. In this post, we’ll cover key PHP-related troubleshooting steps, including error log analysis, configuration tweaks, and performance optimization to ensure that your Nextcloud server runs without a hitch.
Check the PHP Version on Ubuntu 22.04 Server
Currently, my environment is running on PHP 8.2.
php -v
PHP 8.2.23 (cli) (built: Aug 30 2024 09:21:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.23, Copyright (c) Zend Technologies
with Zend OPcache v8.2.23, Copyright (c), by Zend Technologies
Uninstal PHP from Ubuntu 22.04 Server
With commands below, you will be able to remove PHP from your server:
# If PHP is installed using the apt package manager:
sudo apt-get purge php*
# If PHP is installed using aptitude:
sudo aptitude purge php*
# Remove PHP configuration files:
sudo rm -rf /etc/php/
# To remove dependencies or unnecessary packages,
sudo apt-get autoremove
Verify PHP removal:
dpkg -l | grep php
Install PHP 8.2 on Ubuntu 22.04 Server
To install or update your PHP at the server, you can copy the commands from below:
# Install
apt-get update && apt-get upgrade -y
add-apt-repository ppa:ondrej/php
apt install php8.2 -y
apt-get install -y php8.2-cli php8.2-common php8.2-fpm php8.2-mysql php8.2-zip php8.2-gd php8.2-mbstring php8.2-curl php8.2-xml php8.2-bcmath
IMPORTANT: PHP Version 8.3 is recommended by Nextcloud Homepage.
Check Current PHP Version / Disable Older PHP
Main PHP configuration file location is under:
- PHP CLI:
/etc/php/8.2/cli/php.ini
- Apache:
/etc/php/8.2/apache2/php.ini
# Check which version are installed and select correct PHP Version
update-alternatives --config phar.phar
There are 3 choices for the alternative phar.phar (providing /usr/bin/phar.phar).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/phar.phar.default 100 auto mode
1 /usr/bin/phar.phar.default 100 manual mode
2 /usr/bin/phar.phar7.4 74 manual mode
3 /usr/bin/phar.phar8.1 81 manual mode
Press <enter> to keep the current choice[*], or type selection number: ^C
# Disable all not needed PHP Version
a2dismod php8.0
a2dismod php7.4
# Enable installed PHP version
a2enmod php8.2
# Restart web server
sudo systemctl restart apache2
List All the Installed PHP modules
Modules are stored under /etc/php/8.2/mods-available directory.
PHP Active modules configuration directory location:
- PHP CLI: /etc/php/8.2/cli/conf.d/
- Apache: /etc/php/8.2/apache2/conf.d/
Nextcloud Talk Issue Related to the PHP
Nextcloud Talk issue is related to the php-intl package, which provides internationalization support for PHP applications.
To install this package, you need to follow the following steps:
# Stop services
sudo systemctl stop apache2
sudo systemctl stop mariadb.service
# Install the package
sudo apt install php-intl
# Start services
sudo systemctl start apache2
sudo systemctl start mariadb.service
Please check my other articles related to the Nextcloud:
- NextCloud: Maintenance with OCC Command with Practical Examples
- Nextcloud: My Experience Collected in 2 Years of Use