Knowledgebase

Default PHP is not configured

If the default PHP is not configured on your server, you'll need to set it up. Here's how you can do it:

  1. Determine Available PHP Versions:

    First, check which PHP versions are available on your server. You can do this by running:

    bash

 

  • php -v

    This will list the installed PHP versions.

  • Choose a Default PHP Version:

    Decide which PHP version you want to set as the default. You can choose from the available versions listed in step 1.

  • Set Default PHP Version:

    The method for setting the default PHP version can vary depending on your server's configuration. Here are two common methods:

    Method 1: Using a Command Line Tool (such as update-alternatives):

    On some Linux distributions, you can use the update-alternatives command to set the default PHP version. For example:

    bash
  • sudo update-alternatives --set php /usr/bin/php7.4

    Replace /usr/bin/php7.4 with the actual path to the PHP binary of the version you want to set as default.

    Method 2: Through Web Server Configuration (Apache or Nginx):

    If you're using a web server like Apache or Nginx, you can configure it to use a specific PHP version. For Apache, you'll need to adjust the LoadModule directive to load the correct PHP module. For Nginx, you'll need to configure the fastcgi_pass directive.

  • Restart Web Server:

    After setting the default PHP version, you'll need to restart your web server for the changes to take effect. Use one of the following commands based on your web server:

    For Apache:

    bash

 

sudo systemctl restart apache2

For Nginx (if using PHP-FPM):

bash

 

  • sudo systemctl restart php-fpm sudo systemctl restart nginx
  • Verify Default PHP Version:

    To ensure that the default PHP version has been set correctly, run:

    bash
  • php -v

    This should display the version you've set as default.

  • Configure PHP Settings:

    Now that you have a default PHP version, you can further configure it by editing the php.ini file. This file contains various settings that control how PHP behaves.

    bash

 

  1. sudo nano /etc/php/7.4/cli/php.ini

    Adjust the settings as needed.

Remember that the exact steps may vary depending on your server's operating system and configuration. Always ensure you have backups and consider the implications of changing the default PHP version on your applications and websites.

 
  • 0 Users Found This Useful
Was this answer helpful?