php files are blank + source shows php code

Hi all

I’m new to this forum and new in Linux.
I have a virtual machine with OpenSuse 11.2 on it. I’m trying to create a webhost with apache2 and PHP5.
The apache is running and works OK, but I can’t get PHP to work.
When I browse to a php-file on my “server” it shows a blank page, and when I view the source of that page I can read the php-code I wrote. So I’m thinking that PHP does not compile or executes these pages…

I already tried several manuals/tutorials on how to install Apache+php, but none seem to work. The last time I also tried to set up the “HTTP-SERVER” via YAST, but it gives me the same result, HTML files are working, but PHP files give me a blank page with the php code in the source…

Anyone who can help me?
Or who has a proper tutorial on how to install apache + php (in a very simple way) :slight_smile:

Start the software installer, select the Pattern View, tick the pattern “Web and LAMP Server”. This will pull in all packages for your LAMP (Linux Apache MySQL PHP). Create a file “index.php” containing


<?php
echo "PHP working NOW !!";
?>

Create a folder “test” in the root folder of your site (on openSUSE /srv/www/htdocs), and copy the “index.php” in it. Now browse to http://yourdomainname_or_ip/test and you should see PPH working NOW !!

Tested and working here.

Good luck, get back here if you don’t succeed.

Thanks for the quick reply.
I’ve set up a clean installation. I started YAST and did everything you described.
After installation I’ve created an index.php file in a subdir (test).
Unfortunately it is not working :frowning: I’m having a “page cannot be displayed”, also the regular index.html is not showing. Do i need to start some services or something?

ok, it is working now, I’ve disabled the firewall.
But Still, 1 more question.
The PHP-engine only compiles when the script starts with “<?php”, is there a way to also have “<?” recognized?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can configure PHP to accept “short-open tags” but it doesn’t really
benefit you at all and it is not the default for anything anymore. It
would be better to just search/replace through your code and use <?php ?>
instead since it is always going to work.

Good luck.

deefeketje wrote:
> ok, it is working now, I’ve disabled the firewall.
> But Still, 1 more question.
> The PHP-engine only compiles when the script starts with “<?php”, is
> there a way to also have “<?” recognized?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJLYazaAAoJEF+XTK08PnB55agP/1/90Rdf417SauuL71S5opld
uU9F8jTa83YOQcFfK/fVXp0/YFNuyfL7zK5JgPUegdi5mXDkPWkMd6HiDOw7Upfs
HNjBxF8hnk1kk1PuwwGHUemys/VvsEiCl8C/F9Fh08i4yp8QLkmVRXqhJeXbJicR
EsteWiWCnzGOzAAe6+usODB5A0uxYjHozO68DwU40cN8f5DzkeOeajVzIx4GO6c0
ptMKX6IyCYVQuRSIjoq0s2p45w2MHsznj4LnnBR5/bl2WAHC+mlmBqJhHln1MM2a
iC4VPtFGRP/VQMpPhTaChLBgN3SA0/u6V2CNF+qkTHH9PrOENhQejsTBqYd9FaGb
eDqJsGX63BLimeEJcid+jc+iw+wyJAXA5BS5MIGtv/6FPF69aglaJN2dwjS1XN1x
KLGDaywOjLFuw/6b8myexW09YJ93PIyoKXNFGfGOK/OIhEtxXxLkZOdvzEfGDqPs
jqv4so8htx+nDC4elrW0BAXRe6Lev0wqhOM6PqYtT8y/IrKsH9mxot6vgkFsAUOy
IiRqHqKEZKSelv35xObY/sqLHKv7TfLlDz7UrTbgyaDEKWb4kbahGRIsSOjJ4kDk
XzgSJdGVIQVLnyh+MaxRMU7iB1ZM2Y8kjr4n2oR1U4WH4M8b74wNe5c/1nQTandk
KiJbk1Yqas/FVYLSvo1z
=BCTg
-----END PGP SIGNATURE-----