REGISTER  


Apache2 with php - how to get them working together
This thread belongs to expert.forumgeeks.net


2008-12-07 17:25 GMT   |   #1
 
I have a OpenSuSE 11.0 system with Apache2 and PHP loaded. Apache2
runs fine. I have created a .php file and tried to execute the php
file, but my browser wants to download the script file instead of
executing it. How do I tell Apache2 to execute it?

Thanks!
2008-12-07 17:25 GMT   |   #2
 
What ? I tried to execute the php file ? Sounds like either you or me is
confused !

So you've configured Apache2 to enable php scripting ? Use ->Yast ->
Network Services -> HTTP Server -> On the second page you have 'Enable PHP
Srcipting' enabled ?

Then you created a web page with the php code included and put it in your
web folder (srv/www/htdocs) with the proper permissions ? Then you
restarted Apache in a terminal:

1. sudo /etc/init.d/apache2 restart

And then you opened your browser to http://localhost ?

Or am I just in a parallel universe ?
2008-12-07 19:33 GMT   |   #3
 
Sorry, wanted Apache2 to run the .php file. Used to configuring
Apache2 manually and didn't know there was an opting under network
services to reconfigure Apache2.
I now have php5 enabled and restarted Apache2. Went to the web
site: http://www.whatever.com/index.php and Firefox still wants to
download the .php file.
Parallel universe? I'd like to switch places with my duplicate.
2008-12-07 20:01 GMT   |   #4
 
Just and FYI, I restarted the browser, firefox, and now when I go to
http://www.whatever.com/index.php, the browser now shows the script,
instead of downloading it or running the .php script.
2008-12-07 20:06 GMT   |   #5
 
Do I have to do something in the virtual hosts file, for the site,
to enable scripting?
2008-12-11 12:41 GMT   |   #6
 
A while back I was having a problem using pre-generated php files and
someone told me they would not work via locahost but you had to have Apache
running on a different machine than the browser was running on.

I haven't had an opportunity to try that yet, so I can't verify it, but it
does sound very logical - php is server software and the browser is client
software.

It should work if server and client are virtualized on the same hardware.

2008-12-11 16:25 GMT   |   #7
 
A while back I was having a problem using pre-generated php files and
someone told me they would not work via locahost but you had to have Apache
running on a different machine than the browser was running on.

They will work via localhost if you use a browser and have apache on
localhost serve the pages to you. In other words, won't drag-and-drop
the file into the browser but use:

http://localhost/path/to/file.php

and it will/should work[0].
And you can use both on the same machine.
Doesn't matter where the server and client are. As long as the server
serves up the page, rather than the browser reading the file from disc,
you should get the interpreted results rather than the raw script.


[0] It does locally. To make sure my pages do exactly what I want them
to do, I test them writing them in a directory under ${HOME}/public_html
and then going to the page using this sort of address as the URL:

http://localhost/~${MY_USERNAME}/testing.php
2008-12-11 16:25 GMT   |   #8
 
I'm starting to believe that the OP has mucked things up by manually editing
his php config file(s). Usually, when you use Yast to configure Apache and
place the '.php' file in the /srv/www/htdocs folder and point the browser
there 'http://localhost/'my-php-file.php' and it shows the 'contents' of
the file rather than the generated file then either Apache is configured
wrong, php is not enabled or php is misconfigured...

At least that is my experience from the past...

To greatly simplify things try this test php file called phpinfo.php:

<?php phpinfo(); ?>


Pretty simple but does the job.

Just point your browser to http://localhost/phpinfo.php

Don't forget to do this after placing the file in the web folder:

sudo /etc/init.d/apache2 restart
2008-12-11 17:25 GMT   |   #9
 
I was thinking the same thing. Also the most easy way to go is only use
what openSUSE offers you and first see if the above works. If not, then
first solve that before editing anything else.

I thibnk that in the past there were some more example pages for all
sorts of things, but then it could be that that was just with my
provider.

So /srv/www/htdocs/phpinfo.php and all that it needs to have is the line
<?php phpinfo(); ?>
Nothing more and certainly nothing less.
Once all that is done, you can start configuring things to your own
liking. As long as the above does not work, there is no reason to go on
untill it is solved.