For those who are awake!
Discount -15%
We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

4.4.14. Enabling PHP handler for the web server

In some cases, after installing the web server, the PHP handler may not be connected. The connection method depends on the installed web server.

To enable PHP handler in Apache do the following:

  1. Connect to the server via SSH.
  2. Change to the web server directory by running the command:
    cd /etc/httpd/
  3. Check for the PHP module by running the command:
    ls /etc/httpd/modules/ | grep php

    The output should be something like this:

    libphp*-zts.so
    libphp*.so
  4. Check your Apache config files by running the command:
    grep -n 'php' /etc/httpd/conf/*
    1. If the previous command didn't output anything, check for additional configuration files by running the command:
      grep 'Include conf.d\/\*.conf' /etc/httpd/conf/*
      1. If the command also did not output anything, edit the Apache configuration file with the option to load additional configuration files by running the command:
        echo "Include conf.d/*.conf" >> /etc/httpd/conf/httpd.conf
      2. If the command output was like /etc/httpd/conf/httpd.conf:Include conf.d/*.confthen additional configuration files are included.
      3. Check for the PHP configuration file by running the command:
        ls /etc/httpd/conf*/* | grep php
        1. If the previous command did not output anything, create a configuration file by running the command (instead of X specify the PHP version you want):
          cat > /etc/httpd/conf.d/php.conf <<EOF
          <IfModule prefork.c>
            LoadModule phpX_module modules/libphpX.so
          </IfModule>
           
          <IfModule !prefork.c>
            LoadModule phpX_module modules/libphpX-zts.so
          </IfModule>
           
          AddHandler phpX-script .php
          AddType text/html .php
           
          DirectoryIndex index.php
           
          php_value session.save_handler "files"
          php_value session.save_path    "/var/lib/php/session"
          php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"
          EOF
    2. If the command executed in step 4 or 4.a.III produced a result (as a rule, it will be similar to the text specified in step 4.a.III.A), then compare the PHP versions specified in the configuration file with the result of the command performed in step 3. If they are different, replace the version in the corresponding configuration file by opening it for editing with the command:
      nano /etc/httpd/conf*/*.conf

      Specify the desired version instead of the symbol X in lines like this:

      LoadModule phpX_module modules/libphpX.so
      LoadModule phpX_module modules/libphpX-zts.so
      AddHandler phpX-script .php

      Modify a specific config file depending on the previous step:

      • If the previous step was 4, then you need to edit the file /etc/httpd/conf/httpd.conf.
      • If the previous step was 4.a.III, then you need to edit the file /etc/httpd/conf.d/php.conf.
  5. Restart Apache by running the command:
    service httpd restart
    • If the restart was successful, check the PHP functionality on the sites.
    • If errors occur during restart, check the configuration files for line break issues or incorrect parameters.