# A site reports "open_basedir restriction in effect"

UrbeStack sysadmin note about PHP. Last updated 30 Nov 2026.

A site fails to write a file under `/tmp`, and PHP logs `open_basedir restriction in effect`. You can fix the write by using the site's own temporary folder or changing a domain setting.

## Symptoms

The domain's PHP log, shown by `urbestack-domain-log --name example.com --type php`, contains both lines.

```output
[30-Nov-2026 08:26:55 UTC] PHP Warning:  file_put_contents(): open_basedir restriction in effect. File(/tmp/notes-ob.txt) is not within the allowed path(s): (/home/USER/files:/usr/share/php) in /home/USER/files/web/example.com/public_html/ob.php on line 1
[30-Nov-2026 08:26:55 UTC] PHP Warning:  file_put_contents(/tmp/notes-ob.txt): Failed to open stream: Operation not permitted in /home/USER/files/web/example.com/public_html/ob.php on line 1
```

## Cause

UrbeStack sets the domain's `open_basedir` to allow only its owner's home, `/home/USER/files`, and `/usr/share/php`. PHP refuses paths outside those folders, including the shared `/tmp`.

PHP uses `/home/USER/files/tmp` for uploads, sessions, and its own temporary files. The restriction on the shared `/tmp` affects only sites that write to a literal path under `/tmp`.

## Resolution

Set the application's temporary folder to `/home/USER/files/tmp`, or have the application use `sys_get_temp_dir()`, which returns that folder.

If the application needs the shared `/tmp`, only an administrator can give the domain's PHP access to it.

```
urbestack-domain-set --name example.com --php-setting open_basedir_tmp=on
```

Retry the file write after either change. To disable access to the shared `/tmp` again, use `open_basedir_tmp=off`.

If the problem persists after you follow this note, you can [open a support ticket](https://support.urbestack.com/new?type=support). Including the output of the commands you ran helps support diagnose the problem.
