cPanel & WHMScriptingWeb Servers

Mismatch between target UID PHP Log Internal Server Error

When visiting your websites you might be presented with an Internal Server Error. You should check the error log to find out what the exact issue is that is causing this problem. You can search the Apache log for the user in question which will show you the precise error. To search the Apache error log you can use the “grep” feature. This guide deals with errors related to Mismatch between target UID in the log files.

>> Automated way of checking files and folders have the correct user and permissions

We’re going to search for the user First2Host and display the latest log entries for this user

grep "First2Host" /usr/local/apache/logs/error_log | less

This brings back a list of errors We’re just going to focus on the Mismatch between target UID (1223) and GID (99) error and resolve the problem.

[Wed Oct 25 20:37:44.683243 2017] [:error] [pid 31549] [client 192.168.0.44:5225 9] SoftException in Application.cpp:462: Mismatch between target UID (1223) and GID (99) of file "/home/First2Host/public_html/index.php"

As the error log shows, the ownership of the file index.php located in the public_html folder is wrong. The file has a UID of 1223 which is the user First2Host but has a GID of 99 which is nobody. The server was expecting a UID of 1223 and a GID of 1223 and this is causing an Internal Server Error 500.

You  can also check the ownership and permissions on a file or folder in your NVMe VPS by using the stat command;

stat /home/First2Host/public_html/index.php
 
File: '/home/First2Host/public_html/index.php'
Size: 418 Blocks: 8 IO Block: 4096 regular file
Device: 22h/34d Inode: 45635011 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1223/First2Host) Gid: ( 99/nobody)
Access: 2017-10-25 22:18:33.662462339 +0100
Modify: 2017-10-08 22:36:15.000000000 +0100
Change: 2017-10-25 22:05:55.163463029 +0100
 Birth: -

Change File Ownership

To change the ownership of files and folders you can use the chown command.

chown First2Host. /home/First2Host/public_html/index.php

This will change the ownership / GID  of the file to the user First2Host and should correct the problem being seen in the error log. It’s likely other files will also have the wrong ownership settings so let’s see if we can find other files and folders with the ownership of nobody

find /home/First2Host/ -type f -ls | egrep -v 'First2Host (First2Host|mail)' | grep 'nobody nobody' | wc -l
4444

The user First2Host has 4444 files set to the ownership of nobody, all these will need to be changed. We can run a  reclusive command to change the ownership of these files;

chown -R First2Host. /home/First2Host/public_html/*

This will change the ownership of all files and folders within /home/First2Host/public_html/ to the Uid and Gid “First2Host”.

Performing some functions like changing the PHP handler will mean some files have the wrong permission. There is an automated way to check all files and folder permissions in cPanel. You can read our blog post on this if you have a lot of files or indeed a whole server that needs to be checked for the correct permissions.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button