New Posts  All Forums:Forum Nav:

PHP/Apache help

post #1 of 17
Thread Starter 
Sorry, this isn't a Linux question, but a lot of the guys in the Linux section know thier stuff a lot better than I do.

My problem: trying to learn PHP. I don't have the time to learn Linux first, though I may try Vixta or Lindows or Kubuntu as they seem easier. Anyway, I tried following multiple tutorials, and I just don't know what I'm doing enough to even get this set up.

I installed Apache 2.2.4 (site said 2.2.6 on Windows has lots of problems) and installed the latest PHP, 5.2.4. Every single config it said I should change either in http.conf or in php.ini was already done. If I try to open a .php file with internet explorer, it would say php_something.dll (and about 15 other dll files) not found. I found them, right where they're supposed to be, php/ext folder.

So I uninstalled all that, and installed WAMP instead, thinking it might be easier. Now when I try to open the php files, it just displays the code in internet explorer. At this point, I'm out of ideas. I'm relatively sure a small config change would work perfectly, but I don't speak C, C++, or any Unix languages at all, and I just can't figure out what I did wrong. One problem I likely have is that my book is copyright 2002, though the tutorials I found were titled things like "Installing Apache and PHP on Windows Vista" with latest versions.

Screenie of my IE:
post #2 of 17
Quote:
So I uninstalled all that, and installed WAMP instead, thinking it might be easier. Now when I try to open the php files, it just displays the code in internet explorer. At this point, I'm out of ideas. I'm relatively sure a small config change would work perfectly, but I don't speak C, C++, or any Unix languages at all, and I just can't figure out what I did wrong. One problem I likely have is that my book is copyright 2002, though the tutorials I found were titled things like "Installing Apache and PHP on Windows Vista" with latest versions.
Based off the URL you are using in IE, you are attempting to open them incorrectly to not see the code. YOu are opening the file directly, which does not involve Apache, PHP, or anything, it might as well be a text file at that point. What you need to do is find out what port Apache is bound to on your computer, usually 80, and then connect to your own computer's network interface, and with the correct URL to view the PHP as it would be executed by Apache... Meaning, lets for example say your IP address is 10.0.0.43 Apache we will assume is bound to port 80, which is the standard most likely And in the folder that apache treats as the root for your web server, you have the files test.php and index.html Going to the following in IE should open up a web page... http://10.0.0.43:80/index.html Going to the following should execute the PHP script http://10.0.0.43:80/test.php In most cases, the :80 wouldn't be needed if Apache is bound to port 80, but it is there as it gives you a reference in case Apache is not bound to port 80, that is where you would specify the port it is bound to. Also if you have files in a subdirectory of your web server root folder, that should be included in the URL just like you would expect. So lets assume you have, in your web server root folder... php/file.php images/scrap.png To get to those files with the above values I mentioned you would go to... http://10.0.0.43:80/php/file.php and http://10.0.0.43:80/images/scrap.png Make sense for you? And if so does that fix your problem? Seablade
post #3 of 17
Thread Starter 
For the most part it makes sense, but I also think it's going to suck. If I go to whatismyip.com, and put that in my browser, I get my DSL modem. After the DSL modem, there is also a hardware firewall (though 80 should be open by default...) that may give me headache.

In case anyone else ever reads this thread, since I set up apache with "localhost" instead of a domain name, using either my local IP (which you may not have if you are DHCP) or \localhost\filename, it works like a charm... except I have a sytax error on line 7, but that's my own fault.

Thanks Seablade, that was a way easier solution than I ever would have thought.

On a side note, does this mean I can host my own website on my own computer THAT easily? Would I even need a domain name if I had the IP address? I don't really have any desire to do that, but I don't know much about web hosting etc either. I have fleeting HTML knowledge and I can work backwords through some PHP, but that's about all I know about the inner workings of the 'net.
post #4 of 17
Well first things first, the command ipconfig typed into a command prompt window will return your IP address for your interface on windows
Quote:
On a side note, does this mean I can host my own website on my own computer THAT easily? Would I even need a domain name if I had the IP address? I don't really have any desire to do that, but I don't know much about web hosting etc either. I have fleeting HTML knowledge and I can work backwords through some PHP, but that's about all I know about the inner workings of the 'net.
Assuming your firewall is set up correctly, yes that will host your website, and yes you can address an IP address directly without a domain name, again assuming firewall/routing is set up correctly. I wouldn't recommend this yourself though, especially on a windows machine, as without knowing various security risks and a basic understanding of what everything means that you are doing, you open yourself up to a whole new world of ways to compromise your machine. After you learn a bit more though you might feel free, but take your time and learn a bit more first IMO. Not trying to be insulting, just honest. Seablade
post #5 of 17
Thread Starter 
No, I wasnt about to try it, just curious. I use IPconfig nonstop, probably the only command-line thing I've ever relied on. But, we're on DHCP here, so that would only work until I rebooted.

So, now I have another question. I copied all of the folders and files from my website into the proper directory on my PC. It works... sorta. None of the $include things seem to work, so it won't show any headers/footers/etc. Is that normal? If I wanted to only preview page-by-page, I could have used Dreamweaver...
post #6 of 17
Without seeing the entire setup, I couldn't answer that sorry.

Seablade
post #7 of 17
Thread Starter 
If you've got nothing better to do, what part of the setup would you need to see? I don't have any confidential information, nor is it a private site of any kind. Not a huge deal, and I don't expect anything of you so if you don't want to, don't feel pressured.

Basically, I'm trying to build a test environment so I can add a shopping cart system like www.cartweaver.com or something and be able to thoroughly test it out first... that said, having the includes (and any other scripts that may not be working) up and running would give great peace of mind.

EDIT bottom of page also says

Code:
510) echo ", and we will be open until 5:00 PM."; else echo ". Submit...

rather than displaying the time function it is supposed to have, so it seems none of the actual scripts are running correctly. PHP is backwards compatible isn't it? Like, our site is a few years old, maybe it was done in PHP 4? Maybe they have something other than PHP on it that I don't know about?
post #8 of 17
I don't know enough PHP to be able to answer the question without research, that is why I would need the entire setup, to start with configuration files and programming and do research in order to answer it. Sorry.

If you want you can post the PHP file and I can see if I notice anything off on it, but beyond that, there are to many variables that I have to do research myself to be able to solve, to be able to effectively give advice on it.

Seablade
post #9 of 17
Thread Starter 
Additional info:

I created a new page, using dreamweaver as I figured it might be able to make something work easier than I could just doing it off the top of my head, to test an include funciton.

My original site gives no error messages, it merely doesn't include anything or run any scripts.

This time, I do get errors. My two pages, test.php and includeme.php are coded like so:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
asdlfjlkasdjf;laksdjf;askldjf
<?php include(includeme.php); ?>
</body>
</html>
and
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
include me please
</body>
</html>
The result looks like this:
Quote:
asdlfjlkasdjf;laksdjf;askldjf
Warning: include(includemephp) [function.include]: failed to open stream: No such file or directory in C:\\wamp\\www\\test.php on line 10

Warning: include() [function.include]: Failed opening 'includemephp' for inclusion (include_path='.;C:\\php5\\pear') in C:\\wamp\\www\\test.php on line 10

Are these coded correctly? I mean, I know my site works online, but it has some extra stuff in there about [DOCUMENT_ROOT] and stuff that I don't know what it does so I thought I'd try a quick and simple test like this... sadly, it didn't work either.
post #10 of 17
Thread Starter 
Well, no worries Seablade. If anyone else happens across this, I'll keep checking it. I think I'll head over to a PHP-oriented forum and see what I can dig up there. Thanks again.
post #11 of 17
Thread Starter 
I accidentally figured something out. On my test files, posted above, adding a ' to the beginning and end of includeme.php made that include work... so now, I just have to figure out why the ones from my website, which work when they're online, don't work on my localhost...
post #12 of 17
With what you posted, I would look at your PHP configuration files...
Code:
asdlfjlkasdjf;laksdjf;askldjf
Warning: include(includemephp) [function.include]: failed to open stream: No such file or directory in C:\\wamp\\www\\test.php on line 10

Warning: include() [function.include]: Failed opening 'includemephp' for inclusion (include_path='.;C:\\php5\\pear') in C:\\wamp\\www\\test.php on line 10
Note the paths that are listed, by default that is where PHP is searching for files to be included. (See the part about (include_path='.;C:\\php5\\pear') I am not sure if this can be modified by environment variables, the PHP config files, or whatnot. Judging by the layout of that message, I would bet either an environment variable, or a variable defined in the PHP config file. Enclosing the files in single quotes however likely made it look locally for the files instead, which is what you were expecting, which is why it worked. So on whatever host you were hosting this previously, it had something set up to account for that, most likely either an environment variable or a config file. Again I would have to look it up to know for sure what though. Seablade
post #13 of 17
Thread Starter 
Aright, so I ran an echo $server[document_root] or whatever it was, and it has a folder tree four folders deep. So, on my apache server, it probably doesn't get that, but I'm sure it queries the server to ask it where it should be looking... why it doesn't work, I don't know. There has to be something in apache that when queried, it's returning a folder I don't want it to return... Any idea of where I'd look for that? I assume in it's config file, but running a quick search for "php5/pear" didn't give me anything.
post #14 of 17
Actually I would bet that is in your PHP config, not Apache config. But I can't be sure.

Seablade
post #15 of 17
Thread Starter 
that makes sense now that I think about it, but cheeeeeeeeese and rice that's a huge doc. Might take me a day or two to decide if it's there or not :P. A quick search of "document_root" and "php5/pear" didn't give me anything.
post #16 of 17
Do a search in the config file for include_path

Also check and see if include_path is an environmental variable set on your system.

Seablade
post #17 of 17
Thread Starter 
include_path has been set to a comment. I removed the semicolon and tried the document root as well as the folder that the include files are in with no results. Doc_root is set properly, documentroot in apache config is set... I kind of think the problem may be more related to the $SERVER variable, but I don't know how to remove the $SERVER and still know that the [DOCUMENT_ROOT] part of the script will work, as I'm a noob to PHP.

This troubles me a bit too "No such file or directory in C:\wamp\www\home2.php"

That, to me, says that it is looking at the file thinking its a directory... Like, it's looking for C:\wamp\www\home2.php\include\headers.php, which it's never going to find. I've tweaked the code a few times, removing periods, adding periods, adding apostrophes and parentheses, whatever I can think of in my inexperienced head. No idea what to do other than make a copy (which I did, thus "home2") and re-code the includes, then use that file for viewing header.php and footer.php.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux & Other OS's