Prerequisites
Before setting PHP versions, make sure you have:
- Multiple PHP versions installed
- Access to HestiaCP control panel
Check Available PHP Versions
ssh hxroot@YOUR_SERVER_IP -p 22
update-alternatives --list php
Or:
ls /usr/bin/php*
Method 1: Change via HestiaCP Web Interface
Step 1: Log in to HestiaCP
https://YOUR_SERVER_IP:8083
Step 2: Navigate to WEB Section
Click on WEB in the top menu bar.
Step 3: Edit Domain
Click the gear icon (⚙️) next to your domain.
Step 4: Change PHP Version
Under Advanced Options, find PHP Version dropdown.
Select the desired PHP version (e.g., PHP 8.1, PHP 8.2).
Step 5: Save
Click Save to apply.
Method 2: Change via SSH
/usr/local/hestia/bin/v-change-web-domain-backend-tpl admin example.com php8.2
Where php8.2 is the backend template name.
Install Additional PHP Versions (Ubuntu/Debian)
Add PHP repository:
add-apt-repository ppa:ondrej/php
apt update
Install PHP 8.0:
apt install php8.0 php8.0-fpm php8.0-mysql php8.0-curl php8.0-xml php8.0-zip -y
Install PHP 8.1:
apt install php8.1 php8.1-fpm php8.1-mysql php8.1-curl php8.1-xml php8.1-zip -y
Install PHP 8.2:
apt install php8.2 php8.2-fpm php8.2-mysql php8.2-curl php8.2-xml php8.2-zip -y
Verify PHP Version for Domain
Create test file:
echo "" > /home/admin/web/example.com/public_html/phpinfo.php
Visit https://example.com/phpinfo.php and check PHP version.
Set Default PHP Version System-Wide
update-alternatives --set php /usr/bin/php8.2
✅ PHP version per domain has been configured successfully!