I have recently decided to experiment with my own LAMP server and consider creating and hosting my own web dynamic web pages. I have configured everything correctly to this point (I think). I haven't made the server accessible from the outside yet, but can access it on my network and can see my index.htm page.
I created a small php file to see if I've done it right:
<HTML>
<HEAD>
<TITLE>PHP Testing</TITLE>
</HEAD>
<BODY>
<?php
echo "if this works, we <i>really</i> did it!";
?>
</BODY>
</HTML>
when I call the file in a browser, I see the code, not the echo'd text. The code Looks correct to me, but I am super new at this. Is it the code or the configuration?
I have recently decided to experiment with my own LAMP server and consider creating and hosting my own web dynamic web pages. I have configured everything correctly to this point (I think). I haven't made the server accessible from the outside yet, but can access it on my network and can see my index.htm page.
I created a small php file to see if I've done it right:
<HTML>
<HEAD>
<TITLE>PHP Testing</TITLE>
</HEAD>
<BODY>
<?php
echo "if this works, we <i>really</i> did it!";
?>
</BODY>
</HTML>
when I call the file in a browser, I see the code, not the echo'd text. The code Looks correct to me, but I am super new at this. Is it the code or the configuration?
How are you opening the file, just by using File Open or whatever your browser calls it? That won't be going through your server, so it won't be interpreting any PHP. (For example, you can open HTML files on your hard drive in your browser even if you don't have a server installed!) What you have to do is something like: localhost/helloworld.php. You have to have the helloworld.php file in the "document root" that is defined for your Apache server.
It's advisable to post the code in question, otherwise we can't help you out on the specifics (or many times at all).
I listed the code that created my test file in the original post. I believe the code is correct, I will be looking into my configuration to figure out the problem.
How are you opening the file, just by using File Open or whatever your browser calls it? That won't be going through your server, so it won't be interpreting any PHP. (For example, you can open HTML files on your hard drive in your browser even if you don't have a server installed!) What you have to do is something like: localhost/helloworld.php. You have to have the helloworld.php file in the "document root" that is defined for your Apache server.
I called the document from the browser of another machine. I am able to see HTML files, but whenever I put php code in (and change the extension to .php), the output is the code, not the expected echo'd text.
That does sound like Apache isn't configured properly. Review your httpd.conf file. Be sure the paths are correct in the lines that look like this (your paths will probably be different):
Carlo Gambino wrote:I was looking for httpd.conf to find it blank. Are there guidelines for setting this file up?
Oh, wow! Something bad happened when you installed your Apache web server! That should be a very large file! You should reinstall Apache, then PHP. Did you install each of them separately or use one of the WAMP server packages that installs everything at once?
Carlo Gambino wrote:I installed them individually.
Also, I'm using a LAMP setup, windows makes me uncomfortable.
Sorry for jumping to conclusions. I fully understand your discomfort. Usually Apache installations come with a default config file and often with several special config files for particular setups, such as virtual hosting. The file will probably be over 400 lines in length. Currently I don't have Apache installed on my Linux machine, so I can't directly give you the filenames, etc., but if you will Google linux apache config, you will find many good references. Probably all you will need to do is copy one of the existing config files to httpd.conf. Then if PHP still doesn't work, you will only have to uncomment or add a couple of lines to the file.
In case you're not, you need to open php pages through your webserver by pointing the browser to something like http://localhost/myphppage.php
If you try to directly open a php page from the filesystem, you'll just see the php code since the page is not going through a web server to interpret the php.
I overlooked one part of the configuration. I was considering using ISPConfig, which suggested disabling php globally to be enabled on a per site basis:
So I removed the "#" and now php seems to be working. Upon reviewing httpd.conf, the file is still blank, but my phptest.php page displays the php info.
Carlo Gambino wrote:I was looking for httpd.conf to find it blank. Are there guidelines for setting this file up?
Oh, wow! Something bad happened when you installed your Apache web server! That should be a very large file! You should reinstall Apache, then PHP. Did you install each of them separately or use one of the WAMP server packages that installs everything at once?