PHPEnv: Run Different PHP Versions Side by Side on Ubuntu

Running multiple PHP versions on the same server or development machine is never straightforward. One distro upgrade can break packages and turn your environment into a mess. For example, Ubuntu 20.04 ships with PHP 7.4, 22.04 comes with PHP 8.1, and 24.04 will use PHP 8.3. But what if you have projects that require both old and new PHP versions at the same time? That’s where PHPenv comes in. It’s an excellent tool for local development—and even for UAT servers.

To demonstrate how to use different PHP versions side by side, I’ll first install WordPress on Ubuntu 20.04 using Ansible. After that, I’ll set up PHPenv and switch to PHP 8.2.5 using pfm. The first part focuses on WordPress with Ansible, but if you want to skip straight to the PHPenv setup, feel free to jump ahead.

Continue reading “PHPEnv: Run Different PHP Versions Side by Side on Ubuntu” →

Upgrade Nagios Core from source

Upgrading Nagios core from source was remove from official documentation, so I leave that here. Change nagios-4.5.11 with the version you want to upgrade to.

sudo systemctl stop nagios.service
cd /tmp/
sudo rm -rf nagioscore*
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.5.11.tar.gz
tar xzf nagioscore.tar.gz
ll
cd nagioscore-nagios-4.5.11/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
sudo make install
sudo make install-daemoninit
sudo systemctl start nagios.service
sudo systemctl status nagios.service

Create new Linux user on Ubuntu server with SSH public access key only

Add the user

sudo useradd -s /bin/bash -d /home/userubuntu/ -m -G sudo userubuntu

Create authorized_keys file and put you public ssh key

mkdir /home/userubuntu/.ssh/
chmod 0700 /home/userubuntu/.ssh/

sudo -- sh -c "echo 'put the ssh-rsa public key here' > /home/userubuntu/.ssh/authorized_keys"
sudo chown -R userubuntu:userubuntu /home/userubuntu/.ssh/

Allow the user to use sudo without password, type sudo visudo and edit the file, adding userubuntu ALL=(ALL) NOPASSWD:ALL like this

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
dimitar ALL=(ALL) NOPASSWD:ALL

Allow only public key access, no password allowed. sudo vim /etc/ssh/sshd_config

ChallengeResponseAuthentication no
PasswordAuthentication no
PermitRootLogin no
PubkeyAuthentication yes
UsePAM no

restart the ssh service : sudo systemctl restart sshd