<p>According to the <a href="http://uk3.php.net/features.safe-mode" rel="nofollow noreferrer">PHP Safe Mode Docs</a> on safe_mode_gid:</p>

<blockquote>
  <p>By default, Safe Mode does a UID compare check when opening files. If you want to relax this to a GID compare, then turn on safe_mode_gid. Whether to use UID (FALSE) or GID (TRUE) checking upon file access.</p>
</blockquote>

<p>To a PHP script running on a web server, what is the difference between a UID (User Identifier) check and a GID (Group identifier) check?</p>

[{'answer_id': 7863, 'author': 'Armandas', 'author_id': 1024, 'author_profile': 'https://Stackoverflow.com/users/1024', 'pm_score': 1, 'selected': False, 'text': '<p>Safe mode UID check is used to prevent users from accessing other peoples files. GID is used to prevent a GROUP of users from accessing other GROUPS files.</p>\n'}, {'answer_id': 7894, 'author': 'pix0r', 'author_id': 72, 'author_profile': 'https://Stackoverflow.com/users/72', 'pm_score': 2, 'selected': False, 'text': '<p>This will just allow you a little more flexibility in your web server setup.  Using safe_mode_gid, you should be able to run individual PHP/httpd processes for each user on your system, but give each process the ability to read some shared files as long as they are all run as the same group (GID) and the shared files are owned by this group.</p>\n'}, {'answer_id': 31490, 'author': 'paan', 'author_id': 2976, 'author_profile': 'https://Stackoverflow.com/users/2976', 'pm_score': 2, 'selected': False, 'text': "<p>For example the webserver username and group is <b>apache:www</b>,</p>\n\n<p>if you set your to check UID, the php process will only have access to any file owned by the user <b>apache</b>. So if you have another webserver running on your system,for example tomcat with the username and group of <b>tomcat:www</b>, any files created by the tomcat process won't be accessible by php because it is owned by the <b>tomcat</b> user.</p>\n\n<p>But if you instead use GID check, the files created by the tomcat process will be readable by the php process because the belong to the same <b>www</b> group</p>\n"}, {'answer_id': 3778009, 'author': 'Capsule', 'author_id': 181206, 'author_profile': 'https://Stackoverflow.com/users/181206', 'pm_score': 1, 'selected': False, 'text': '<p>Most answers are not exactly true or detailed... Don\'t forget <code>safe_mode</code> checks if the owner of the SCRIPT matches the owner of the file you want to access. It has nothing to do with the httpd user:group.</p>\n\n<p>For example, your httpd could run as <code>apache:daemon</code>, your script owned by <code>some_user:users</code> and the file you want to write to <code>some_other_user:users</code>.</p>\n\n<p>If you don\'t activate <code>safe_mode_gid</code>, the script won\'t be able to access the file because users don\'t match.</p>\n\n<p>This is a common phenomenon when a script creates a folder and then tries to create files inside this folder.</p>\n\n<p>The folder creation succeeds because the parent folder is owned by the same user as the script creating it (most likely, it was uploaded by "some_user").</p>\n\n<p>BUT, the created folder is now owned by the httpd user, let\'s say <code>apache:daemon</code></p>\n\n<p>If <code>safe_mode</code> is active, you won\'t be able to create a file inside this folder because the script owner (<code>some_user</code>) doesn\'t match the folder owner (<code>apache</code>).</p>\n\n<p>Even if you activate <code>safe_mode_gid</code>, it won\'t work because the script group is "users" while the folder group is "daemon".</p>\n\n<p>The best solution is to set the same group for ftp users and httpd.\nDon\'t forget you have to allow write access to the group on the "writeable" folder too, and this is less secure because since all your users are in the same group, an httpd process could access the other users files since you activate <code>safe_mode_gid</code>.</p>\n\n<p>You should in fact combine <code>safe_mode_gid</code> + <code>open_basedir</code> and set the home of the user as <code>open_basedire</code> value to avoid this.</p>\n\n<p>HTH</p>\n'}]
['https://Stackoverflow.com/questions/7851', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/840/']