The Blog


Updating Ubuntu 22.04 PHP from 8.1 to 8.2

Posted on
sudo dpkg -l | grep php | tee packages.txt
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update
sudo apt install php8.2 php8.2-cli php8.2-{bz2,curl,mbstring,intl}

sudo apt install php8.2-fpm
# OR
# sudo apt install libapache2-mod-php8.2

sudo a2enconf php8.2-fpm

# When upgrading from older PHP version:
sudo a2disconf php8.1-fpm

## Remove old packages
sudo apt purge php8.1*
Posted in Uncategorized Leave a comment

Ubuntu 22.04 LTS + Plesk 18 + PHP 8.1 + Symfony 6.1 and so on

Posted on

First issue after installing all of that was symfony-cli could not find Plesk’s PHP, this fixed it.

sudo ln -s /opt/plesk/php/8.0/bin/php /usr/local/bin/php

Next issue was “KnpMenuBundle” in 6.1 it needs to be used as a service, see here. Also if you want custom template the path needs to be set this way; if your template is in “templates/Menu/knp_menu.html.twig”


    # use 'twig: false' to disable the Twig extension and the TwigRenderer
        template: Menu/knp_menu.html.twig
    #  if true, enables the helper for PHP templates
    templating: false
    # the renderer to use, list is also available by default
    default_renderer: twig

Another issue was, how to use raw SQL in symfony 6, very simple thanks to auto-wiring.

Few samples of raw SQL for MySQL:

# get connection
$conn = $managerRegistry->getConnection();

# sample 1
$sql = "SELECT * FROM somethingWHERE id = :user_id";
$resultSet = $conn->executeQuery($sql, ['user_id' => 123]);
$results = $resultSet->fetchAllAssociative();

# sample 2
$sql = "SELECT * FROM something";
$result = $conn->fetchAllAssociative($sql);
Posted in Symfony 6, Uncategorized Leave a comment

Running multiple instances of MySQL on the same server.

Posted on

Starting point.

Below is another alternative, but this one seems to be a better way to go.

Above needs to be done in my.cnf and not the “.d” folders.

Copy /etc/mysql/my.cnf to /etc/mysql/my2.cnf
Also copy conf.d and mysql.conf.d to conf2.d and mysql.conf2.d
Update all the files in them to point to new data location and lock file needs to be in the /tmp/ location.

Pointing to the New Data Location

MySQL has several ways to override configuration values. By default, the datadir is set to /var/lib/mysql in the /etc/mysql/mysql.conf.d/mysqld.cnf file. Edit this file to reflect the new data directory:

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf 

Find the line that begins with datadir= and change the path which follows to reflect the new location.

In our case, the updated file looks like the output below:/etc/mysql/mysql.conf.d/mysqld.cnf

. . .
. . .

This seems like the right time to bring up MySQL again, but there’s one more thing to configure before we can do that successfully.

Step 3 — Configuring AppArmor Access Control Rules

We’ll need to tell AppArmor to let MySQL write to the new directory by creating an alias between the default directory and the new location. To do this, edit the AppArmor alias file:

sudo nano /etc/apparmor.d/tunables/alias

At the bottom of the file, add the following alias rule:/etc/apparmor.d/tunables/alias

. . .
alias /var/lib/mysql/ -> /var/lib/mysql2/,
. . .

For the changes to take effect, restart AppArmor:

sudo systemctl restart apparmor

Now we can start new MySQL

shell> mysqld_safe --defaults-file=/etc/mysql/mysql2.cnf &

Posted in Uncategorized Leave a comment
Next Page »