I've posted this over at WMW, but the suggestions so far have not worked - not that the SUGGESTIONS are necessarily bad - it could be I don't know what I'm doing and I'm missing something simple...anyway, figured I'd try here, too, just in case...
SUMMARY:
How do I use includes in my pages residing in the subdomain of my main site? Naturally the includes work fine on the main domain, but I cannot figure out how to get includes to work for the subdomain pages - please read on for more details which explain what I have already tried.
THE FULL MAGILLA:
Now, I'm posting this in this section because I'm by no means a web developer, programmer, sysadmin, etc.
I do have a couple of small, active sites which hum along, and I've learned a lot in building them, but this is my first foray into the world of subdomains. *shudder*
My problem is this:
I am trying to use php includes in the subdomain pages - but cannot get them to show on the live page.
Some back-ground:
1 - I'm on a virtual dedicated server, so I have full access to "my" server.
2 - Obviously it's running php (Linux/Apache - I never know how to properly say this like "It runs Windows" ) - (I am a dumbass, I know)
3 - All includes work fine on the main website
Now, I have been at this for about 6 hours so far today and here's a run-down on what I've tried (and what has failed). I'll try to do this justice as I know a wrong character or misplaced space can cause things to go awry... (f-ing .htaccess files! I love them now, but hated them for about 3 hours one cold, dreary Sunday... LOL)
The main website is structured as such:
http://www.domain.com/file-name.html
Includes reside as:
http://www.domain.com/includes/nav.php
Images, same dealio...
Now, on the main domain, I use the following code to bring in the includes:
<?php include('includes/test_header.php');?>
Brings it in on a "relative path", if I'm using the correct terminology there.
Now, dropping this code into the test page (http://subdomain.domain.com/template-page.html) I have in the subdomain (http://subdomain.domain.com/) nets me squat.
I have the following folders created in the subdomain:
/includes/ /images/
Now, the confusing part for me is that I do actually have the php files I want included inside this /includes/ folder in the subdomain. If I type the direct path for the file into the address bar, it shows up nicely.
Images are pulled into the subdomain test page properly (from the /images/ folder in the subdomain).
I have tried the following combinations of include code and more - all of which have failed to be successful (the actual file I'm testing for is named "sc_header.php" ):
<?php include("subdomain.domain.com/includes/sc_header.php" );?> (quotes, no "http://" )
<?php include("http://www.domain.com/includes/sc_header.php" );?> (tried calling from the main domain's include folder - no joy - tried this with quotes & apostrophies, with and without the "http://" )
<?php include('domain.com/subdomains/nameofsubdomain/httpdocs/includes/sc_header.php' );?> (this one with quotes and apostrophies and every permutation of inclusion or removal of listed items in the path - with and without "httpdocs", for example.
Heck, I even just tried dropping the file into the root of the subdomain and calling it from there - again, zip.
I've searched threads here, at php.net and generally through Google today - nothing helped point me in a direction that worked. I did find some ideas of things I hadn't tried, but when I did try them, nada.
I came across some references to "cgi-bins", but not being a programmer, etc., I have no clue what they are, how to set them up or how to use them. I'm hoping for a simple solution to this problem, rather than a lessons in yet another new item to learn.
So, there we go folks - I'll throw myself at your mercy.
As I mentioned near the beginning of this post - I am NOT a web developer, programmer or sysadmin - it's been a long, frustrating journey to learn what I know on my own, and I am still firmly encamped in my "Noob Webmaster" status.
I'd appreciate any partical suggestions and idea that are directly applicable to solving this problem.
I clearly am missing something in my understanding of what works with subdomains...
**Please Note: in the code smaples above, I have added a space between " & ) or ' & ) as this forum makes them appears as winking smileys... In the actual coding on the live webspage those spaces do not exist.**
[ Message was edited by: SportsGuy 05/29/2006 07:23 am ]
Is the server set up to not allow files to be used by other websites (like disabling hotlinking) - although is a SUBdomain considered a different site? Just a thought.
Seems to me if you type the path/filename in your browser, run it, copy that - it should work.
Is the server set up to not allow files to be used by other websites (like disabling hotlinking) - although is a SUBdomain considered a different site? Just a thought.
Seems to me if you type the path/filename in your browser, run it, copy that - it should work.
Interesting you should bring this up. This is NOT the case right now, but I was going to edit the .htaccess file later this month to bump MySpace off for just such a thing.
At WMW, one poster suggested it *might* be the redirect I have for the non-www to www thing. Can't see it myself, though, as it specifies the actuall non-www version to be redirected AND, the page loads fine - it's the include that's screwy.
SportsGuy, don't see your file structure from 'web' point of view i.e. domain.com/filename or subdomain.domain.com/filename
Use file manager or FTP software to see actual file structure.
On root directory you may find 'public_html' directory and 'www' shortcut to that directory. I called this as 'web root'. Use your file manager located in your hosting control panel or use some ftp software to find where your subdomain directory is located. Generally it is located in public_html. Give the correct 'server path' for include file. It's working on my server so it should work on yours too.
I have following file permissions:
public_html 750
Other folders in public_html 755
include file 0644
php file that uses include file 0644
Well, I tried every combo I could think of using the path shown to me in my ftp client. Nothing worked.
I'm seriously bummed about this now.
Here's the path as laid out when using the IE as the FTP tool (it's the same basic path I see when trolling through things in my server interface - the only difference I see is the ftp portion, which I'd expect using an ftp interface):
I swapped the ftp for http, then tried it without anything - just domain.com, etc., etc... With the www and without. Obviously after the last / I have the file name in there (sc_header.php) for all permutations.
I even changed the view permissions on the "httpdocs" folder everything sits inside to ensure "ALL" was selected in the "View" list. All other file sin the path were already set this way.
Looks like I arrived a bit late on the scene. One caveat: sending server passwords by PM is not recommended.
Let's get down to the meat of the matter here.
As I am a little short of time, I reproduce what I have understood from the long message here.
1. You want to include a file
2. And the file is somewhere in the includes directory.
When it comes to servers, it is prudent to do one thing: Don't assume something unless it is proved.
You call up the included file from your browser like so:
http://your_domain.com/includes/included.php
If you can see the file, then copy and paste the same URL in your include statement. If you have enabled log_errors = On in your php.ini, you could see where the error is.
If the above step fails for any reason, try and include another file with some simple HTML statements from the same directory.
I suggest that you enable the log_errors = On in your php.ini temporarily to check the source of error.
I suggest that you enable the log_errors = On in your php.ini temporarily to check the source of error.
I'm all for it...
Where the heck do I look t find that file and what/how do I change it?
I just looked around on my server and saw squat even remotely resembling this php.ini file.
To cover a couple other points:
1 - if I type the direct path to the include file into my address bar, it shows perfectly.
2 - I've built the test page to call an image from the image folder located in the subdomain area - works perfectly, too.
Ok. Stick this in a file called test.php and view this in your browser:
<? phpinfo();
?>
That will show you a nicely formatted details about your server and its PHP configuration.
Look for this :
Configuration File (php.ini) Path :
Note the path your php.ini's location and open this file in a text editor. Make sure you issue a command like the following ( to make a backup of the original file)
cp php.ini php.ini.orig
I assume that you have a SSH access to do this. You will not be normally permitted to navigate into the 'internal' regions of the server by FTP.
From the Shell prompt you can type vi php.ini to open the text editor with the php.ini
Scroll down to the area where you have an entry like so:
; - log_errors = On
Remove the ; and you are set to log the errors.
whilst at it you might want to check the following out:
safe_mode = Off
safe_mode_include_dir =
After your changes, save the file and restart apache. I know it all sounds a little complicated for the uninitiated, but if you follow the directions, you can do it.
Alternatively you can ask the server admin to set the parameters as per your direction. All managed servers still have a sysadmin who is responsible for their upkeep.
Do I replace "SERVER" and "DOCUMENT ROOT" with anything, or do they stay as typed above?
2 - I am now seeing that phpinfo stuff - VERY informative, I must say - not that I understand much of it, but still.
3 - I went looking for the php.ini file where the phpinfo doc suggests it resides - cannot see it anywhere in that folder.
4 - Tried the "include path" outlined for the website in the template page, nada - hell, I relocated the include item to the normal (domain.com) "includes" folder and told the doc the full path ot it, and tried the abbreviated path, too - still nothing.
EX - I tried:
http://www.domain.com/includes/sc_header.php as the path suggested in the phpinfo doc is .:/domain.com/httpdocs/includes
...and...
/includes/sc_header.php
All of it a big fat nothing.
WTF is goig on here that I cannot get a simple include to work in a subdomain? Images will call in fine form the "images" folder in the subdomain, but includes will not...
[ Message was edited by: SportsGuy 06/01/2006 08:38 am ]
Do I replace "SERVER" and "DOCUMENT ROOT" with anything, or do they stay as typed above?
ANSWER - I think I do - see below:
Found the following items in that phpinfo page:
1 - server = www.domain.com - replaced SERVER with that
2 - document root = /var/www/vhosts/domain.com/httpdocs, so I replaces DOCUMENT_ROOT with that data.
I added a space in there to make sure the smiley wouldn't appear when this is posted - right here: header.php';SPACE);?>.
...and still nothing works.
I tried adding a couple of folders into the doc_root string (domain/com/subdomains/sports-cars/ and it didn't work.
I'm beginning to think there's a setting on the server which instructs the system on how to handle subdomains only - but I have no idea - it's just a guess to try to "pin down" the problem.
$_SERVER['DOCUMENT_ROOT'] is a server environment variable. You don't substitute it with anything else. The server will fill in the details when it runs it.
Your problem is really a matter of configuration. Hardly a cause to celebrate when you can't fix the issue.
Now on to your questions:
>> 2 - I am now seeing that phpinfo stuff - VERY informative, I must say - not that I understand much of it, but still.
Remember to delete this file after you are done with the testing.
>> 3 - I went looking for the php.ini file where the phpinfo doc suggests it resides - cannot see it anywhere in that folder.
The whole thing hinges on your modifying this file. I would assume that you had looked for this file from a Shell prompt. If you can send me this file, I will set this in a development server and set the parameters to make your includes work and send it back.
No way. I agree messing with the configuration settings is a bit daunting. But with patience and a little guidance, it can be tackled.
Look for Shell Access in Your Plesk. I don't have a Plesk enabled server at the moment. It will take you to something which looks like the MS DOS prompt. That gives you complete access to the server albeit in a cryptic fashion.
It is a small Windows SSH client and enter your server IP address/domain name and set the protocol to SSH in the radio button. It will open a DOS like window and ask for user name and password. You might have to enable this SSH from your Plesk control panel.
Once there, you can navigate to the directory pointed out by your PHP information page. You will need to know a bit of unix/linux command to list the directory etc.
OK, so I found the shell access. Opened it, the java applet started to load, then I get a bunch of errors on the screen...
I'm really getting frustrated with this freaking problem - it's been weeks and every single thing which was suggested both here and at WMW I've tried - without success. Well, I've tried what I could, learned about things I didn't understand, and tried again - and failed again and again.
Should this not just be as simple as using includes in the html files for the main domain?
I'd like to simply give up, walk away from this idea and just throw everything I want to create into a new FOLDER in the mian domain. Trouble is, it deserves to be subdomained - it's related, but distant enough to not make sense in a FOLDER. Plus, we're talking 300 - 400 new pages - pages with ads on them...
Am I the only person online who's ever encountered this freaking problem? *sigh*
You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
You have not yet logged in, or registered properly as a member
You are a member, but no longer have posting rights.
This is a private forum, for which you do not have permissions.
If you are a recent member, it's possible that you simply have not yet confirmed your account. Please
check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions
contained within.
If you are still experiencing problem, please read the
Login Assistance
Article for some advice on what may be causing your login not to work properly.