Ubuntu
Basic actions
- Before updating PHP, if Passwork is installed in a cloud/virtual environment, create a snapshot of the virtual OS state to restore functionality in case of incorrect update;
- Obtain
rootprivileges and update the local package database:
- shell
sudo -i
apt-get update
Removing PHP
Determine the PHP version:
- shell
php -v
Depending on the PHP version used (8.0 or 8.2), use the following commands to remove the outdated version.
Disable the module for the Apache2 web server:
- 8.2
- 8.0
a2dismod php8.2
a2dismod php8.0
Remove the main package, drivers, and PHP extensions:
- 8.2
- 8.0
apt-get remove -y php8.2 php8.2-*
apt-get remove -y php8.0 php8.0-*
Remove the directory with nested PHP files:
- 8.2
- 8.0
rm -rf /etc/php/8.2
rm -rf /etc/php/8.0
Installing PHP
Install PHP and extension modules:
- shell
apt install -y php8.3-cli php8.3-bcmath php8.3-fpm php8.3-curl php8.3-gd php8.3-intl php8.3-ldap php8.3-mbstring php8.3-mysql php8.3-opcache php8.3-pgsql php8.3-soap php8.3-zip php8.3-sqlite3 php8.3-xml php8.3-dev php-pear
Installing PHP MongoDB driver
Install the PHP MongoDB driver:
- shell
pecl install -f mongodb
Create configuration files to load and enable PHP MongoDB:
- shell
echo "extension=mongodb.so" | tee /etc/php/8.3/fpm/conf.d/20-mongodb.ini
echo "extension=mongodb.so" | tee /etc/php/8.3/cli/conf.d/20-mongodb.ini
Force enable PHP for Apache2 and switch the alternative version for executable files:
- shell
update-alternatives --set php /usr/bin/php8.3
update-alternatives --set phar /usr/bin/phar8.3
update-alternatives --set phar.phar /usr/bin/phar.phar8.3
Changing PHP handler of the web server to php-fpm
Make sure the php8.3-fpm service is running:
- shell
systemctl status php8.3-fpm
Start and enable autostart of the service if it is stopped:
- shell
systemctl start php8.3-fpm
systemctl enable php8.3-fpm
Edit the Passwork server virtual host configured to work over HTTPS:
- shell
nano /etc/apache2/sites-enabled/default-ssl.conf
Change the .php file handler by specifying proxying requests to the php-fpm socket:
- shell
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
Check that the virtual host configuration file matches the example:
- shell
<VirtualHost *:443>
ServerName passwork:443
DocumentRoot /var/www/public
<Directory /var/www/public>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
</VirtualHost>
Enable modules and restart services:
- shell
a2enmod rewrite proxy_fcgi setenvif
systemctl restart php8.3-fpm
systemctl restart apache2