Server version: Apache/2.4.34 (Unix)

I'm trying to utilize an existing SSL certificate for several sub-directories of a domain, but the architecture for the domain separates out two directories for non-secure/secure:


I copied everything from httpdocs to httpsdocs and also forced traffic to https using .htaccess. Everything worked great until I tried the PHP file upload functionality.

Here's the bit of code that is failing from the secure side:

$path = "uploaded_files/".$row_query[0].'/'.$file_name;
copy($temp_file, $path);

In doing some debugging, I found that the temp file gets created: /tmp/phpanKT4N

but the error I see in the logs is: copy(uploaded_files/New Sub Folder/30052_testing.txt): failed to open stream: Permission denied in /var/www/vhosts/.com/httpsdocs/demo/resource/add_resource.php on line 108

I tried changing copy() to move_uploaded_file() but here's the error for that:

PHP Warning:  move_uploaded_file(uploaded_files/test/30054_testing.txt): failed to open stream: No such file or directory in /var/www/vhosts/<thedomain>.com/httpsdocs/demo/resource/add_resource.php on line 111
PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpOC9YEF' to 'uploaded_files/test/30054_testing.txt' in /var/www/vhosts/<thedomain>.com/httpsdocs/demo/resource/add_resource.php on line 111

I searched stack and saw that ownership must match, but the permissions appear to be the same for httpdocs and httpsdocs.

The /tmp folder is owned by root:root and like I said this works perfectly from the non-secure folder. The non-secure and secure upload folders are identical:


drwxrwxr-x+  8 theuser apache  4096 Sep 22  2015 uploaded_files


drwxrwxr-x+  8 theuser apache  4096 Sep 22  2015 uploaded_files

Is this a configuration, permissions issue, or what?


Figured this out... Ran the following:

First find apache's user:

egrep -i '^user|^group' /etc/httpd/conf/httpd.conf 

Result: User apache Group apache

Then ran this and it solved all the PHP file upload issues in httpsdocs:

chown -R apache:apache /var/www/vhosts/<thedomain>.com/httpsdocs/
chmod -R g+rw /var/www/vhosts/<thedomain>.com/httpsdocs/

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.