Re: Re: fopen permission denied

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey Jeffry,

 Yes as I demonstrated a few messages back this file belongs to the apache
web server account.

[root@web1:/etc/httpd] #egrep -i "user|group" conf/httpd.conf  | grep -i -v
-e logformat -e '#'
User apache
Group apache

[root@web1:/etc/httpd] #ls -l /var/www/php-webdev/orders/orders.txt
-rw-r--r--. 1 apache apache 115 Dec 28 14:46
/var/www/php-webdev/orders/orders.txt

And I have seen apache run as  'nobody' or 'www-data' (if you're on
debian/ubuntu). I've even seen apache run as some variation of the company
name that I'm working for. But I've also seen apache in production
environments. From what I can gather running apache as 'apache' is a CentOS
/ RedHat default.

Cheers,
Tim

On Sun, Dec 28, 2014 at 10:10 PM, Jeffry Killen <jekillen@xxxxxxxxxxx>
wrote:

>
> On Dec 28, 2014, at 11:34 AM, Tim Dunphy wrote:
>
>  Hey guys,
>>
>> I found the issue. The problem was that I'm on CentOS and I was using
>> SELinux!! Well I'm not much of an SELinux user. So I just turned it off
>> like this:
>>
>> [root@web1:/var/www/php-webdev] #setenforce 0
>> [root@web1:/var/www/php-webdev] #
>>
>> [root@web1:/var/www/php-webdev] #getenforce
>> Permissive
>> [root@web1:/var/www/php-webdev] #
>>
>> And now the script works as designed:
>>
>> Bob’s Auto PartsOrder Results
>>
>> Order processed at 14:31, 28th December 2014
>>
>> Your order is as follows:
>> Items ordered: 8
>> 1 tires
>> 2 bottles of oil
>> 5 spark plugs
>>
>> Total of order is $140.00
>>
>> Address to ship to is 39 Carmen Court
>>
>> Order written.
>>
>> Thanks for your suggestion! But I'm glad that did it!
>>
>> Tim
>>
>> On Sun, Dec 28, 2014 at 1:34 PM, Tim Dunphy <bluethundr@xxxxxxxxx> wrote:
>>
>>  Hi James,
>>>
>>> Ok, so I tried taking your advice. And set the mode and group
>>> accordingly:
>>>
>>> [root@web1:~] #ls -lh /var/www/php-webdev/orders/orders.txt
>>> -rw-r--r--. 1 apache users 0 Dec 27 21:47
>>> /var/www/php-webdev/orders/orders.txt
>>>
>>> However the result didn't change. I get the same failure when trying to
>>> write to the file:
>>>
>>> *Warning*: fopen(/var/www/php-webdev/orders/orders.txt): failed to open
>>> stream: Permission denied in */var/www/php-webdev/ch01/processorder.php*
>>> on
>>> line *50*
>>>
>>> Thanks
>>> Tim
>>>
>>> On Sun, Dec 28, 2014 at 1:27 PM, James Moe <jimoe@xxxxxxxxxxxxxx> wrote:
>>>
>>>  On 12/28/2014 11:03 AM, Tim Dunphy wrote:
>>>>
>>>>> -rwxr-xr-x. 1 apache apache 0 Dec 27 21:47
>>>>> /var/www/php-webdev/orders/orders.txt
>>>>>
>>>>>  Is there a reason why it is marked as an executable? Such files are
>>>> normally 0644 or 0664.
>>>>
>>>> Another option is to set the group to "users" and add apache to that
>>>> group.
>>>>
>>>> --
>>>> James Moe
>>>> jmm-list at sohnen-moe dot com
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>>
>>>
>>> --
>>> GPG me!!
>>>
>>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>>>
>>>
>>>
>>
>> --
>> GPG me!
>>
>
> There is one other technicallity to consider:
> Does the file your trying to read/write to belong to the web server user
> account?
> (I have never seen the Apache web server run as Apache. It is most often
> _www,
> or nobody or something else)
> JK




-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux