LinuxQuestions.org
Help answer threads with 0 replies.
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 02-03-2011, 02:35 AM   #1
petruha1983
LQ Newbie
 
Registered: Feb 2009
Posts: 15

Rep: Reputation: 0
apache - "file_get_contents" works only with port 80?


Hi there,
I have a web site on port 80.
My apache works on port 8080.
i configured cache_module in apache.
so that the clients will enter the web site threw the apache and apache will gather all the cache of the web site in order to speed up the service.
when i point apache to take content from port 80 - it works just fine.
when i change it from port 80 to any other port, it gives an error:
"failed to open stream: Permission denied in /var/www/web/cache/index.php on line 44"

it works fine with port 80. so how come not other port?

i will be glad to hear any suggestion.
 
Old 02-03-2011, 10:16 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
What is on line 44 of the file named in the error message?
 
Old 02-04-2011, 11:57 AM   #3
petruha1983
LQ Newbie
 
Registered: Feb 2009
Posts: 15

Original Poster
Rep: Reputation: 0
this is what i have added in the end of httpd.conf:



####################### Proxy config start #########################

<Directory />
RewriteEngine on
RewriteBase /
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)?(.*)$ cache/index.php?folder=$1$2 [L,QSA]
</Directory>

####################### Cache config start #########################


##LoadModule cache_module modules/mod_cache.so

<IfModule cache_module>

##gfhfhfgdgfh

### LoadModule disk_cache_module modules/mod_disk_cache.so
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On
CacheDefaultExpire 86400
# If you want to use mod_disk_cache instead of mod_mem_cache,
# uncomment the line above and comment out the LoadModule line below.

########### <IfModule mod_disk_cache.c>
########### CacheEnable disk /
########### CacheRoot "/var/cache/mod_proxy"
########### </IfModule>
## disk_cache_module
<IfModule mod_disk_cache.c>


##CacheRoot c:/cacheroot
##CacheRoot "/var/spool/httpd/cache"
##CacheRoot /cache2/

CacheRoot "/var/cache/mod_proxy"
CacheEnable disk /cache/
#CacheSize 5000000

#CacheExpiryCheck Off
#####CacheEnable disk /plugins/cache/
##CacheDirLevels 5
##CacheDirLength 3
</IfModule>

##LoadModule mem_cache_module modules/mod_mem_cache.so
######## <IfModule mod_mem_cache_xxx>
######## ##CacheEnable mem /
######## CacheEnable mem /plugins/
######## MCacheSize 4096
######## MCacheMaxObjectCount 100
######## MCacheMinObjectSize 1
######## MCacheMaxObjectSize 2048
######## </IfModule>

# When acting as a proxy, don't cache the list of security updates
##CacheDisable http://security.update.server/update-list/
</IfModule>

####################### cache config ends #########################



and that is my index.php that rewrites the request:
<?

//phpinfo();die;

/* show error in case you get a blank page*/
ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);
/* show errors end*/

/* Code for Cache: start (Important for Cache) */
header( 'Expires: Mon, 26 Jul 2020 05:00:00 GMT' );
//header( 'Last-Modified: Mon, 02 Feb 2000 13:56:55 GMT' );
header( 'Last-Modified: Mon, 02 Feb 2000 13:56:55 GMT' );
header( 'Cache-Control: public' );
header( 'Pragma: cache' );
/* Code for Cache: ends */

// $server is the parameter for the gis server location (glass fish)
$servers = array();
$servers[] = "http://IP_ADRESS:3080/";
//$servers[] = "http://localhost:8080/";
$server = $servers[array_rand($servers)];

//$server = "http://localhost:8080/";

// Put the query string in $qs
$qs = $_SERVER["QUERY_STRING"];

// $folder: this parameter is coming from apache i.e. http://xyz.com/?QUERY_STRING ->
$folder = $_GET["folder"];

// This line removes var and www and html from $folder
$folder = preg_replace("/var\/www\/web\//","",$folder);

// $new_request will be the call (i.e. in glass fish server) to make
// this is a assamble of the server name + target folder + and query string
$new_request = $server . $folder . "?" . $qs;

// convert the page to an xml result page
header ("content-type: image/jpeg");

// get the new call content and print it
echo file_get_contents ($new_request);

?>
line 44 is the last line

any suggestions to solve my problem?

Last edited by petruha1983; 02-04-2011 at 11:59 AM.
 
Old 07-04-2016, 09:31 PM   #4
fhleung
Member
 
Registered: Aug 2004
Distribution: Lubuntu Live OS
Posts: 432

Rep: Reputation: 30
I did searchED by topic "file_get_contents()" and got this post,
so I would like to append this post, please be understanding...

please simply copy and paste PHP code
Code:
<? php
$text = file_get_contents('http://url.com') ;

// do processing the $text like functions strstr() substr()

echo $text ; output after processing
?>
please simply copy and paste PHP code above.
Questions is: if can code it better? if this secure?
thank you

Last edited by fhleung; 07-04-2016 at 09:33 PM.
 
Old 07-04-2016, 09:42 PM   #5
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
Also, if your system uses selinux you may need to configure selinux to allow your non-standard http ports.
 
1 members found this post helpful.
Old 07-11-2016, 09:06 PM   #6
fhleung
Member
 
Registered: Aug 2004
Distribution: Lubuntu Live OS
Posts: 432

Rep: Reputation: 30
file_get_contents() is PHP function
in the php script, need to flush() functions too?

php AND apache web server could be a web server , putting .html files .php files inside

would it better?
ob_get_contents() - Return the contents of the output buffer
ob_clean() - Clean (erase) the output buffer
ob_end_flush() - Flush (send) the output buffer and turn off output buffering
ob_end_clean() - Clean (erase) the output buffer and turn off output buffering

Last edited by fhleung; 07-11-2016 at 09:09 PM.
 
  


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
"Minicom -s" works, but it always show "Offline", then cannot communicate with others reflecter_chen Linux - Hardware 8 05-14-2016 02:05 PM
evdev/xorg help? USB mouse/kbd: 2.6.24="just works">2.6.25="unplug/replug to work". GrapefruiTgirl Linux - Hardware 4 12-13-2012 02:23 PM
Apache rewrite rule to change any "&" to "%26" d1s4st3r Linux - Server 1 02-25-2010 10:01 PM
Can't get apache "It works" page to come up tekmann33 Linux - Newbie 8 01-05-2007 03:23 PM
"apache startssl" fails: can't bind port 443 mrjamin Linux - Software 4 07-04-2005 11:09 AM

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

All times are GMT -5. The time now is 05:54 PM.

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