GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Too many php includes on one server, is it possible? (https://gfy.com/showthread.php?t=683375)

Jace 12-04-2006 12:32 AM

Too many php includes on one server, is it possible?
 
I have a project I am working on, and a big part of the project is to have this

<a href='<?php include('http://www.domain.com/urlinc/file.php'); ?>'>

everywhere

there are thousands of them

is this putting an extra load on my server? what is wrong with doing it this way?

spasmo 12-04-2006 12:50 AM

The only thing to keep in mind is it's an extra disk hit (hit to the page, and a hit to the include from the page that's calling it).

I use them all over the place on my sites and have yet to become spindle bound.

The pro to using them is it's easy to centralize things (such as headers or metas) so that you can make a global change by editing one file.

Personally, I highly recommend includes when appropriate, and it appears to me that your use is more than appropriate. The alternative would be to have thousands of individual files that contain the same thing your include has.

Hope that helps.

mlove 12-04-2006 12:54 AM

Is the urlinc/file.php file actually remote? I've met many webmasters who actually do this when the file/domain exists on the same machine.

If the file is actually remote, It would probably be better practice to configure a cron job to retrieve an updated version of the file every hour, and include the file locally.

If the file isn't remote, you should not be charging money for your services.

woj 12-04-2006 01:01 AM

if you use:
include('http://www.domain.com/urlinc/file.php');

it will slow it down quite a bit, if possible I would use only local includes like:
include('urlinc/file.php');

Jace 12-04-2006 01:06 AM

Quote:

Originally Posted by woj (Post 11449327)
if you use:
include('http://www.domain.com/urlinc/file.php');

it will slow it down quite a bit, if possible I would use only local includes like:
include('urlinc/file.php');

the file is on the same server, but different domain

mlove 12-04-2006 01:10 AM

Quote:

Originally Posted by Jace (Post 11449356)
the file is on the same server, but different domain

You could always chmod the file 755, and include the file via /home/username/public_html/urlinc/file.php . If you're running cpanel, you will have to add the other homedir to your list of openbasedir allowed paths, which is in httpd.conf .

Jace 12-04-2006 01:10 AM

my main issue has just started tonight

it gives me some wierd error I have never seen before

Warning: php_network_getaddresses: getaddrinfo failed: name or service
is not known in....then it gives the file name and the line #

I restart apache and everything works great again

rowan 12-04-2006 01:10 AM

Quote:

Originally Posted by Jace (Post 11449356)
the file is on the same server, but different domain

Try using the full path.

The way you have it now opens a HTTP connection which is very inefficient (plus it will fill up your web logs)

Jace 12-04-2006 01:11 AM

Quote:

Originally Posted by mlove (Post 11449376)
You could always chmod the file 755, and include the file via /home/username/public_html/urlinc/file.php . If you're running cpanel, you will have to add the other homedir to your list of openbasedir allowed paths, which is in httpd.conf .

how will this benefit? just a more graceful way of doing it?

Jace 12-04-2006 01:12 AM

Quote:

Originally Posted by rowan (Post 11449378)
Try using the full path.

The way you have it now opens a HTTP connection which is very inefficient (plus it will fill up your web logs)

hm, I will give it a shot for sure

I am running a whm/cpanel server, is this possible? to pull from another account?

Jace 12-04-2006 01:13 AM

btw, I have to say, gfy may be idiotic at time, but there are some really knowledgeable people around here, and I thank you all big time for it :)

gfy has saved me from major issues so many times it isn't funny! haha

mlove 12-04-2006 01:19 AM

Quote:

Originally Posted by Jace (Post 11449390)
hm, I will give it a shot for sure

I am running a whm/cpanel server, is this possible? to pull from another account?

In cpanel, they introduced a security feature that tells php what paths your virtualhost is allowed to access. If you don't add the other path into your list of open_basedir allowed hosts, it will fail. You need to open /usr/local/apache/conf/httpd.conf in your favorite editor, and add the path. Then, restart apache. If this is too much for you, i'd be happy to help out.

This will definitely speed your script up though.

Jace 12-04-2006 01:21 AM

Quote:

Originally Posted by mlove (Post 11449441)
In cpanel, they introduced a security feature that tells php what paths your virtualhost is allowed to access. If you don't add the other path into your list of open_basedir allowed hosts, it will fail. You need to open /usr/local/apache/conf/httpd.conf in your favorite editor, and add the path. Then, restart apache. If this is too much for you, i'd be happy to help out.

This will definitely speed your script up though.

well, so far there are no speed issues

the issue has started tonight

Quote:

Warning: php_network_getaddresses: getaddrinfo failed: name or service
is not known in....then it gives the file name and the line #
what does that mean?

mlove 12-04-2006 01:26 AM

Quote:

well, so far there are no speed issues

the issue has started tonight
Are you running this live? If you receive a lot of traffic, you're going to have big problems with your access logs being massive in size, and apache is going to be using more memory, since there will be two connections for every one page view.

Quote:

Warning: php_network_getaddresses: getaddrinfo failed: name or service
is not known in....then it gives the file name and the line #
That's usually a sign of dns trouble. Chances are, apache was having to do so many dns lookups, it got sick of working.

CyberHustler 12-04-2006 01:28 AM

I use dreamweaver

Jace 12-04-2006 01:33 AM

Quote:

Originally Posted by mlove (Post 11449483)
Are you running this live? If you receive a lot of traffic, you're going to have big problems with your access logs being massive in size, and apache is going to be using more memory, since there will be two connections for every one page view.


That's usually a sign of dns trouble. Chances are, apache was having to do so many dns lookups, it got sick of working.

ok, so will what we have gone over in this thread help me? modifying the httpd.conf?

Jace 12-04-2006 01:34 AM

Quote:

Originally Posted by BuySexProducts (Post 11449490)
I use dreamweaver

with every stupid answer like that, you lose 10 customers to Jon Clarks company

mlove 12-04-2006 01:35 AM

Quote:

Originally Posted by Jace (Post 11449507)
ok, so will what we have gone over in this thread help me? modifying the httpd.conf?

Modifying httpd.conf is only to allow your script to access the file while it exists in another user's home directory.

Jace 12-04-2006 01:37 AM

Quote:

Originally Posted by mlove (Post 11449517)
Modifying httpd.conf is only to allow your script to access the file while it exists in another user's home directory.

that is what is happening though

I am setting up /usr/home/domain1/index.php
and it calls the php from
/usr/home/domain2/links.php

mlove 12-04-2006 01:40 AM

Quote:

Originally Posted by Jace (Post 11449526)
that is what is happening though

I am setting up /usr/home/domain1/index.php
and it calls the php from
/usr/home/domain2/links.php

Is this even a cpanel machine? Those aren't the regular paths.

Are you root? You have to be root to edit httpd.conf.

Jace 12-04-2006 01:43 AM

Quote:

Originally Posted by mlove (Post 11449538)
Is this even a cpanel machine? Those aren't the regular paths.

Are you root? You have to be root to edit httpd.conf.

yes, I just threw those paths in off the top of my head...LOL

the path of the actual files being included is: /home/newsfl/public_html/links/link.php

and the path to the domains calling them varies, depending what I registered that day

Jace 12-04-2006 01:44 AM

and yes, I am root, but I have little experience working in ssh

Jace 12-04-2006 01:46 AM

mlove, are you a server tech, and if so, what do you charge? and do you have references?

I have little shit like this that pops up every once and a while, and I would love to have someone on icq that could work with me on it

mlove 12-04-2006 01:51 AM

Quote:

mlove, are you a server tech, and if so, what do you charge? and do you have references?
I am a server tech. I'd be willing to do this free. No gfy references, but my resume can be found at http://mikey.ws/resume.php , I also have a good record with the people at webhostingtalk.com .

my aim is sdrawkcabyekim . No icq, email is [email protected] .

munki 12-04-2006 02:03 AM

You all patched up yet homes?

mlove 12-04-2006 02:14 AM

I'm leaving for sleep. If you still need help, send en email and I'll get to it in the afternoon.

Bro Media - BANNED FOR LIFE 12-04-2006 02:19 AM

Quote:

Originally Posted by Jace (Post 11449207)
I have a project I am working on, and a big part of the project is to have this

<a href='<?php include('http://www.domain.com/urlinc/file.php'); ?>'>

everywhere

there are thousands of them

is this putting an extra load on my server? what is wrong with doing it this way?

my question is why are you doing a php include into a href tag?

Jace 12-04-2006 02:33 AM

Quote:

Originally Posted by Madrox (Post 11449677)
my question is why are you doing a php include into a href tag?

and my question is to you, why, after so many replies, are you the only one that doesn't understand?

Jace 12-04-2006 02:36 AM

Quote:

Originally Posted by mlove (Post 11449662)
I'm leaving for sleep. If you still need help, send en email and I'll get to it in the afternoon.

hey man, I added you to AIM, I will contact you when I get up in the afternoon tomorrow :)

I will email you also, I would love to talk about what my best option is for this to keep my server load at the bare minimum

I also want to speak with you about going through and optimizing my server

Jace 12-04-2006 02:41 AM

Quote:

Originally Posted by munki (Post 11449613)
You all patched up yet homes?

i just hit you up on icq and msn, you are "idle"

J.P. 12-04-2006 03:33 AM

Hi Jace,

this really does not look the way you should be doing it. Why don't you just write a function in that .php file and include it only once? like this:

Code:

<?
include '/full_path/urlinc/file.php;
?>
<a href="<?=get_url();?>">

Of course, the function should be called get_url() and it should return the URL string...

munki 12-04-2006 04:00 AM

Quote:

Originally Posted by Jace (Post 11449720)
i just hit you up on icq and msn, you are "idle"

sex happens... :thumbsup

emthree 12-04-2006 04:13 AM

I always wondered the same.
I have a few thousand pages using phpinclude, I never really noticed any problems.

Jace 12-04-2006 04:20 AM

Quote:

Originally Posted by emthree (Post 11450076)
I always wondered the same.
I have a few thousand pages using phpinclude, I never really noticed any problems.

well, right now I am at 20,000 pages and climbing

Jace 12-04-2006 04:42 AM

Quote:

Originally Posted by J.P. (Post 11449926)
Hi Jace,

this really does not look the way you should be doing it. Why don't you just write a function in that .php file and include it only once? like this:

Code:

<?
include '/full_path/urlinc/file.php;
?>
<a href="<?=get_url();?>">

Of course, the function should be called get_url() and it should return the URL string...

I am not quite sure what you are saying

I have about 20k pages across 50 or so domains, all of them in about 20 niches....I need to call one single url php file to rotate urls on those pages consistantly

why would I include it only once when I have 20 locations on the page I need those urls rotated?

J.P. 12-04-2006 09:04 AM

You can rotate them in the function... As I understand you're always including the same .php, right? And this one .php does a rotation? Couldn't the function do the rotation? If you're including 20 different .php files, then disregard my previous message :)

SmokeyTheBear 12-04-2006 09:11 AM

Quote:

Originally Posted by Jace (Post 11450207)
I am not quite sure what you are saying

I have about 20k pages across 50 or so domains, all of them in about 20 niches....I need to call one single url php file to rotate urls on those pages consistantly

why would I include it only once when I have 20 locations on the page I need those urls rotated?

he is just saying that if you calling the include multiple times in the same file its easier to call it once at the top then just repeat in throughout the file

Bro Media - BANNED FOR LIFE 12-04-2006 11:36 AM

Quote:

Originally Posted by Jace (Post 11449703)
and my question is to you, why, after so many replies, are you the only one that doesn't understand?

i guess i don't understand, because my 3 years doing PHP i have NEVER seen anyone include a php file in a href tag... why not just make it <a href="url.php?1">

then have url.php have

<?php
$link[1] = "somelink.com";

header("location: http://" . $link[$QUERY_STRING]);
?>

RawAlex 12-04-2006 11:43 AM

madrox, he is trying to write the actual link rather than having a php call, it's all about making googlebot happy.

My question would be why not have your php module write the <a href part itself? then you could just call the module rather than calling inside of a link. That is very messy code.

As others have mentioned, never use http:// inside an include. That means you server has to do a lookup (dns), make a connection (to itself, even worse) and use up available apache connection resources to serve you something that can be done directly in PHP without an issue. That will kill your server deader than a doornail in about 2 seconds if you get some hits on the page. Googlebot would be enough to make your server stop running.

u-Bob 12-04-2006 05:14 PM

1. use cron to create file-to-include.txt every hr.
2. use readfile() instead of include() to 'include' file-to-include.txt

Jace 12-04-2006 05:32 PM

all has been solved thank to munki :) he ROCKS

Jace 12-04-2006 05:34 PM

Quote:

Originally Posted by SmokeyTheBear (Post 11451527)
he is just saying that if you calling the include multiple times in the same file its easier to call it once at the top then just repeat in throughout the file

oh ok, i get that

I am going to try and implement that also

munki 12-04-2006 05:47 PM

Quote:

Originally Posted by Jace (Post 11455621)
all has been solved thank to munki :) he ROCKS

:1orglaugh I'm even better sober...


All times are GMT -7. The time now is 04:16 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123