0

I'm facing a Missing a temporary folder error in PHO version (native, 7.2).

I have already tried the bellow method:

define(‘WP_TEMP_DIR’,dirname(_FILE_). ‘/wp-content/temp/’);

but it had no result. Can you give me some solutions?

Dharman
  • 30,962
  • 25
  • 85
  • 135

2 Answers2

0

Add this code in the config

define('WP_TEMP_DIR', dirname(_FILE_) . '/wp-content/temp/');

then create the temp folder manually on wp-content folder :).

suii
  • 292
  • 2
  • 13
0

I've just had the same issue, there are some obvious solutions if you google about it...

In my situation that wasn't working. My setup was:

PHP 7.4.28
Ubuntu 20.4
Apache 2.4.41
WordPress 5.9.2

I came arround this and could finally resolve the error.

In short therms:
The apache2 / httpd systemd service uses PrivateTmp=true, its own version of the tmp dir. This is why wordpress couldn't find its "temporary folder" anymore.

I solved it by commenting out the respective entry in apache2.service: (if you deeply care about security you might find another way to deal with it...)

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=https://httpd.apache.org/docs/2.4/

[Service]
Type=forking
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
# PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

don't forget to:

  • reload deamon: sudo systemctl daemon-reload
  • restart apache: sudo systemctl restart apache2

...

Dharman
  • 30,962
  • 25
  • 85
  • 135