Too many php includes on one server, is it possible?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jace
    FBOP Class Of 2013
    • Jan 2004
    • 35562

    #1

    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
    Confirmed User
    • Dec 2005
    • 2678

    #2
    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.

    Surfers: Go here for hot babes.

    Comment

    • mlove
      the guy
      • Apr 2005
      • 764

      #3
      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.
      If you won't feel as good, I won't feel as cheap.

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47882

        #4
        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');
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • Jace
          FBOP Class Of 2013
          • Jan 2004
          • 35562

          #5
          Originally posted by woj
          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

          Comment

          • mlove
            the guy
            • Apr 2005
            • 764

            #6
            Originally posted by Jace
            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 .
            If you won't feel as good, I won't feel as cheap.

            Comment

            • Jace
              FBOP Class Of 2013
              • Jan 2004
              • 35562

              #7
              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

              Comment

              • rowan
                Too lazy to set a custom title
                • Mar 2002
                • 17393

                #8
                Originally posted by Jace
                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)

                Comment

                • Jace
                  FBOP Class Of 2013
                  • Jan 2004
                  • 35562

                  #9
                  Originally posted by mlove
                  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?

                  Comment

                  • Jace
                    FBOP Class Of 2013
                    • Jan 2004
                    • 35562

                    #10
                    Originally posted by rowan
                    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?

                    Comment

                    • Jace
                      FBOP Class Of 2013
                      • Jan 2004
                      • 35562

                      #11
                      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

                      Comment

                      • mlove
                        the guy
                        • Apr 2005
                        • 764

                        #12
                        Originally posted by Jace
                        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.
                        If you won't feel as good, I won't feel as cheap.

                        Comment

                        • Jace
                          FBOP Class Of 2013
                          • Jan 2004
                          • 35562

                          #13
                          Originally posted by mlove
                          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

                          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?

                          Comment

                          • mlove
                            the guy
                            • Apr 2005
                            • 764

                            #14
                            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.

                            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.
                            If you won't feel as good, I won't feel as cheap.

                            Comment

                            • CyberHustler
                              Masterbaiter
                              • Feb 2006
                              • 28739

                              #15
                              I use dreamweaver
                              “If you can convince the lowest white man he’s better than the best colored man, he won’t notice you’re picking his pocket. Hell, give him somebody to look down on, and he’ll empty his pockets for you.”

                              Comment

                              • Jace
                                FBOP Class Of 2013
                                • Jan 2004
                                • 35562

                                #16
                                Originally posted by mlove
                                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?

                                Comment

                                • Jace
                                  FBOP Class Of 2013
                                  • Jan 2004
                                  • 35562

                                  #17
                                  Originally posted by BuySexProducts
                                  I use dreamweaver
                                  with every stupid answer like that, you lose 10 customers to Jon Clarks company

                                  Comment

                                  • mlove
                                    the guy
                                    • Apr 2005
                                    • 764

                                    #18
                                    Originally posted by Jace
                                    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.
                                    If you won't feel as good, I won't feel as cheap.

                                    Comment

                                    • Jace
                                      FBOP Class Of 2013
                                      • Jan 2004
                                      • 35562

                                      #19
                                      Originally posted by mlove
                                      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

                                      Comment

                                      • mlove
                                        the guy
                                        • Apr 2005
                                        • 764

                                        #20
                                        Originally posted by Jace
                                        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.
                                        If you won't feel as good, I won't feel as cheap.

                                        Comment

                                        • Jace
                                          FBOP Class Of 2013
                                          • Jan 2004
                                          • 35562

                                          #21
                                          Originally posted by mlove
                                          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

                                          Comment

                                          • Jace
                                            FBOP Class Of 2013
                                            • Jan 2004
                                            • 35562

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

                                            Comment

                                            • Jace
                                              FBOP Class Of 2013
                                              • Jan 2004
                                              • 35562

                                              #23
                                              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

                                              Comment

                                              • mlove
                                                the guy
                                                • Apr 2005
                                                • 764

                                                #24
                                                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] .
                                                Last edited by mlove; 12-03-2006, 11:53 PM.
                                                If you won't feel as good, I won't feel as cheap.

                                                Comment

                                                • munki
                                                  Do Fun Shit.
                                                  • Dec 2004
                                                  • 13393

                                                  #25
                                                  You all patched up yet homes?

                                                  I have the simplest tastes. I am always satisfied with the best.” -Oscar Wilde

                                                  Comment

                                                  • mlove
                                                    the guy
                                                    • Apr 2005
                                                    • 764

                                                    #26
                                                    I'm leaving for sleep. If you still need help, send en email and I'll get to it in the afternoon.
                                                    If you won't feel as good, I won't feel as cheap.

                                                    Comment

                                                    • Bro Media - BANNED FOR LIFE
                                                      MOBILE PORN: IMOBILEPORN
                                                      • Jan 2004
                                                      • 16502

                                                      #27
                                                      Originally posted by Jace
                                                      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?

                                                      Comment

                                                      • Jace
                                                        FBOP Class Of 2013
                                                        • Jan 2004
                                                        • 35562

                                                        #28
                                                        Originally posted by Madrox
                                                        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?

                                                        Comment

                                                        • Jace
                                                          FBOP Class Of 2013
                                                          • Jan 2004
                                                          • 35562

                                                          #29
                                                          Originally posted by mlove
                                                          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

                                                          Comment

                                                          • Jace
                                                            FBOP Class Of 2013
                                                            • Jan 2004
                                                            • 35562

                                                            #30
                                                            Originally posted by munki
                                                            You all patched up yet homes?
                                                            i just hit you up on icq and msn, you are "idle"

                                                            Comment

                                                            • J.P.
                                                              Confirmed User
                                                              • Jun 2004
                                                              • 689

                                                              #31
                                                              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...
                                                              Webmasters! Looking for new affiliate programs to promote?
                                                              Affiliate Program Search <-- Search for programs with FHGs, RSS feed, specific niche sponsors, ...

                                                              Comment

                                                              • munki
                                                                Do Fun Shit.
                                                                • Dec 2004
                                                                • 13393

                                                                #32
                                                                Originally posted by Jace
                                                                i just hit you up on icq and msn, you are "idle"
                                                                sex happens...

                                                                I have the simplest tastes. I am always satisfied with the best.” -Oscar Wilde

                                                                Comment

                                                                • emthree
                                                                  Dialer Kingpin
                                                                  • Jun 2003
                                                                  • 10816

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

                                                                  Sell Patches & Pills

                                                                  Comment

                                                                  • Jace
                                                                    FBOP Class Of 2013
                                                                    • Jan 2004
                                                                    • 35562

                                                                    #34
                                                                    Originally posted by emthree
                                                                    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

                                                                    Comment

                                                                    • Jace
                                                                      FBOP Class Of 2013
                                                                      • Jan 2004
                                                                      • 35562

                                                                      #35
                                                                      Originally posted by J.P.
                                                                      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?

                                                                      Comment

                                                                      • J.P.
                                                                        Confirmed User
                                                                        • Jun 2004
                                                                        • 689

                                                                        #36
                                                                        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
                                                                        Webmasters! Looking for new affiliate programs to promote?
                                                                        Affiliate Program Search <-- Search for programs with FHGs, RSS feed, specific niche sponsors, ...

                                                                        Comment

                                                                        • SmokeyTheBear
                                                                          ►SouthOfHeaven
                                                                          • Jun 2004
                                                                          • 28609

                                                                          #37
                                                                          Originally posted by Jace
                                                                          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
                                                                          hatisblack at yahoo.com

                                                                          Comment

                                                                          • Bro Media - BANNED FOR LIFE
                                                                            MOBILE PORN: IMOBILEPORN
                                                                            • Jan 2004
                                                                            • 16502

                                                                            #38
                                                                            Originally posted by Jace
                                                                            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]);
                                                                            ?>

                                                                            Comment

                                                                            • RawAlex
                                                                              So Fucking Banned
                                                                              • Oct 2003
                                                                              • 9465

                                                                              #39
                                                                              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.

                                                                              Comment

                                                                              • u-Bob
                                                                                there's no $$$ in porn
                                                                                • Jul 2005
                                                                                • 33063

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

                                                                                Comment

                                                                                • Jace
                                                                                  FBOP Class Of 2013
                                                                                  • Jan 2004
                                                                                  • 35562

                                                                                  #41
                                                                                  all has been solved thank to munki he ROCKS

                                                                                  Comment

                                                                                  • Jace
                                                                                    FBOP Class Of 2013
                                                                                    • Jan 2004
                                                                                    • 35562

                                                                                    #42
                                                                                    Originally posted by SmokeyTheBear
                                                                                    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

                                                                                    Comment

                                                                                    • munki
                                                                                      Do Fun Shit.
                                                                                      • Dec 2004
                                                                                      • 13393

                                                                                      #43
                                                                                      Originally posted by Jace
                                                                                      all has been solved thank to munki he ROCKS
                                                                                      I'm even better sober...

                                                                                      I have the simplest tastes. I am always satisfied with the best.” -Oscar Wilde

                                                                                      Comment

                                                                                      Working...