4.3.9. 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.
- Connect to the server via SSH.
- Change to your web server directory by running the command:
- Check for the PHP module by running the command:
ls /etc/httpd/modules/ | grep php
The output should be something like this:
- Check your Apache config files by running the command:
grep -n 'php' /etc/httpd/conf/*
- 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/*
- If the command also did not output anything, edit the Apache configuration file, adding it with the option to load additional configuration files by running the command:
echo "Include conf.d/*.conf" >> /etc/httpd/conf/httpd.conf
- If the command output was like
/etc/httpd/conf/httpd.conf:Include conf.d/*.conf, then additional configuration files are included.
- Check for the existence of a PHP configuration file by running the command:
ls /etc/httpd/conf*/* | grep php
- If the previous command did not output anything, create a configuration file by running the command (instead of
Xspecify 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
- 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:
Specify the desired version instead of the symbol
Xin 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
- If the previous step was 4.a.III, then you need to edit the file
- 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 problems or incorrect parameters.