Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

It seems like I cannot do anything with my PHP script on my VPS.

It returns 'Permission denied' when I try to upload something to a directory.

Yes, I have changed the permission to 777, and it works, but I do not like the insecurity

When running the command:

ps axu|grep apache|grep -v grep

It returns

 nobody    7689  0.1  3.8  50604 20036 ?        S    21:38   0:00 /usr/local/apache/bin/httpd -k start -DSSL
root     13600  0.0  3.8  50304 20348 ?        Ss   Jun06   0:46 /usr/local/apache/bin/httpd -k start -DSSL
nobody   15733  0.1  3.8  50700 20156 ?        S    21:39   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   15818  0.1  3.8  51492 20180 ?        S    21:39   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   23843  0.1  3.7  51336 19592 ?        S    21:40   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30335  0.0  3.5  50436 18496 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30406  0.0  3.5  50444 18544 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30407  0.0  3.5  50556 18696 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30472  0.0  3.6  50828 19348 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30474  0.0  3.5  50668 18868 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30476  0.0  3.6  50532 19064 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   30501  0.0  3.8  50556 20080 ?        S    21:36   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32341  0.0  3.5  50444 18492 ?        S    21:41   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32370  0.0  3.5  50444 18476 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32414  0.1  3.7  51336 19524 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32416  0.1  3.5  50668 18816 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32457  0.1  3.6  50828 19320 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32458  0.1  3.6  50772 19276 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32459  0.0  3.5  50444 18504 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32460  0.2  3.6  50828 19320 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32463  0.0  3.5  50444 18472 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL
nobody   32466  0.0  3.4  50436 17960 ?        S    21:42   0:00 /usr/local/apache/bin/httpd -k start -DSSL

The owner of the directory is 'user [505]' and the group is 'user[508]' (as seen in WinSCP)

What can I do to change the Apache Handler to the right owner and group to allow my PHP scripts to work?

P.S

My PHP is not set to safe mode, and the open_basedir is set to no value

EDIT:

This is what my httpd.conf looks like (for the associative domain)

 <VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /home/domain/public_html
ServerAdmin info@domain
## User <theUsername> # Needed for Cpanel::ApacheConf
<IfModule mod_userdir.c>
    Userdir disabled
    Userdir enabled <userName>
</IfModule>
<IfModule mod_suphp.c>
    suPHP_UserGroup <userName> <userName>
</IfModule>
<IfModule !mod_disable_suexec.c>
    SuexecUserGroup <userName> <userName>
</IfModule>
CustomLog /usr/local/apache/domlogs/domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
CustomLog /usr/local/apache/domlogs/domain.com combined
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/
#Options -ExecCGI -Includes
#RemoveHandler cgi-script .cgi .pl .plx .ppl .perl

share|improve this question

3 Answers 3

It will need the same rights as the user that's running the webserver. This will vary depending on your OS. It may be "apache" or "www-data" or something else entirely.

Unless you are using suEXEC, the script is executed by the webserver, and as such is running with the same permissions as that user.

So, to fix the problem, you need to identify what user the apache process is running under, and apply appropriate permissions to the files/folders you want the script to be able to modify.

You can specify the User and Group account apache runs under in your conf file using the

User=[username]
Group=[groupname]

directives.

Have a look in your conf file, again the name and location of the file will vary with OS. Supplying a bit more specifics here may assit with a more direct answer.

edit: for Centos the conf file is located in

/etc/httpd/conf/httpd.conf
share|improve this answer
    
I'm running CentOS... how would I identify what user it is running under? And how Would i change it? Httpd.conf? –  moe Jun 8 '10 at 1:59
    
I've edited my response. –  LukeR Jun 8 '10 at 2:05
    
See my edit, The username and group seem correctly set.. –  moe Jun 8 '10 at 2:09
    
Figured it out, see answer. Thanks for your help! –  moe Jun 8 '10 at 2:15
    
no worries. glad it's sorted. –  LukeR Jun 8 '10 at 2:20

UPDATE! If you're having this problem too try this:

In WHM go to:

Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration

I Changed PHP 5 Handler to: suphp.

Worked a treat

share|improve this answer

change in WHM Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration php hadler >> fcgi,, it will solve the problm..

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.