Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2006, 02:39 PM
Aceman's Avatar
Aceman Aceman is offline
 
Join Date: Mar 2002
Location: Virginia, USA
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP: Script generated files - ownership issue

On my server php scripts that generate files are doing so fine, however the files that the script makes sets the owner of that file as "apache.apache" and I can not remove/overwrite those files unless I log in as root and do so. The script is chmod 777. And the ownership is aceman.aceman, but the files it creates are always apache.apache.

I chown -R aceman.aceman public_html - which recursively sets all the files in the folder and it's sub folders to owner-aceman / group-aceman.

Is there a way to setup the server so that the ownership is maintained? In the php.ini file or the httpd config file?

Any guidance or help would be greatly appreciated.
Reply With Quote
  #2  
Old 02-09-2006, 03:28 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

From Zend's Page on File Creation:

Quote:
Permissions
It is important to remember a few key things when working with PHP and file creation. PHP runs via your webserver and therefore has the same rights as your webserver. Since most webservers do not run with super-user status (root in Unix/Linux, or administrator in Windows) you will need to make sure the folders and files you want to edit allow the webserver write access.

Got that all set? If you already know what you are doing with permissions, you can skip to the next section.

If you are running Unix or Linux with Apache you will need to change the owner of your files to ?nobody? or ?www? depending on your install. If you don?t know what user simply type:

ps -aux | grep httpd

This will show you the apache processes running on your server, look to see the name of the user running the process. Now you need to change the permissions of your files.

File: chown www file.txt
Directory: chown www folder1/

This will change the owner of the file file.txt (or the directory folder1/) to www, thus allowing PHP via Apache to edit the file.
Reply With Quote
  #3  
Old 02-09-2006, 03:32 PM
Aceman's Avatar
Aceman Aceman is offline
 
Join Date: Mar 2002
Location: Virginia, USA
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I actually found that page on another site myself via google. I ran the command they indicated and my server says it's apache. Not nobody or www.

maybe it's a setting issue with the server because mine doesn't say nobody or www - it's apache. Where can I set it so that nobody is the default owner when a file is generated?

Just a heads up: in my httpd.conf file I did notice a line that reads:

User apache
Group apache

Would changing that too nobody for user and group help? And then restart apache?

Aceman
Reply With Quote
  #4  
Old 02-09-2006, 04:13 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It doesn't really matter whether it runs as apache or nobody, it just means the files will be owned by the user "nobody" instead. You need to alter the script that creates them to make sure the created files are global write.
Reply With Quote
  #5  
Old 02-09-2006, 04:25 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You shouldn't have to alter any scripts. It worked fine on the old server but this one is giving us fits for some reason. There has to be a setting somewhere that sets it. And no ones else seems to be having this problem so it has to be server side.
Reply With Quote
  #6  
Old 02-09-2006, 04:42 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could try addind a user aceman, group aceman to the apache definition for that site.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:23 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03924 seconds
  • Memory Usage 2,207KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete