LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-18-2011, 08:26 PM   #1
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Rep: Reputation: 53
apache: optimal read/write location for perl scripts


I'm not quite sure where to have my perl scripts write to/read from in Apache. The data written will be accessed and printed for visitors. Any recommendations? I'm running CentOS 5.5.
 
Old 01-20-2011, 06:15 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Anywhere you like.. your web server can be configured to serve any directory. Don't forget - if you have selinux enabled you'll need to check the context of your data -

# is selinux enforcing?
Code:
getenforce
# .. if result from above is 'enforcing':
Code:
chcon -R --reference=/var/www/html /path/to/my/data

Last edited by kbp; 01-20-2011 at 06:19 AM.
 
1 members found this post helpful.
Old 01-20-2011, 03:03 PM   #3
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Thanks kbp; I think this is what I need. Does this just mean data can be read/written here according to the permissions set for /var/www/html, that /path assumes the same permissions as /var/www/html?
 
Old 01-20-2011, 04:19 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
No .. it tells selinux that this data is web content which means that selinux won't prevent apache from accessing it. In RHEL/CentOS selinux is in targeted mode by default which means that specific applications are protected/restricted, apache httpd is one of them.

If you want to poke around try running 'ls -ldZ /var/www/html' and you'll see that it's type is 'httpd_sys_content_t', apache isn't allowed to serve any directories that aren't the right type. You can see all the possible types by running 'semanage fcontext -l'.

cheers

Last edited by kbp; 01-20-2011 at 04:21 PM.
 
1 members found this post helpful.
Old 01-20-2011, 04:48 PM   #5
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Thanks alot! You've been a great help.
 
Old 01-21-2011, 12:46 PM   #6
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
So if I wanted to set the security context directly, would I run 1)
Code:
chcon -R httpd_sys_content_t /path/to/data
or 2)
Code:
chcon -R system_u:object_r:httpd_sys_content_t:so /path/to/data
 
Old 01-21-2011, 10:41 PM   #7
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
The second one... it's usually easier to use '--reference=/blah' though
 
1 members found this post helpful.
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i get my scripts to read/write text from/to specific parts of files? Siljrath Linux - General 12 02-06-2010 02:58 PM
to access(read/write) location 0x08 topworld Programming 4 10-31-2006 04:39 AM
Perl scripts in different location Suinatsa Programming 9 05-03-2006 12:06 PM
how to write scripts for testing a appln using PERL sgayodhya Linux - Software 0 11-20-2004 03:23 AM
learning to write Perl CGI scripts djgerbavore Programming 1 10-19-2004 12:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration