PHP files download for fresh LAMP install

Hi

I’ve been working through the LAMP tutorial here:

SDB:Linux Apache MySQL PHP - openSUSE

I’ve installed the default “Web and LAMP Server” package as instructed and I’m falling down at the “Confirming PHP works” stage, with the PHP file downloading instead of running. As the guide instructs I’ve attempted adding a line to the /etc/apache2/mod_userdir.conf file, but to no avail. A little net surfing points me in so many directions that I just don’t know where to look.

Given that this is a new install under OpenSUSE 13.1, can I get some experienced views on where I go next?

Thanks

Stuart

Hey Stuart,

I guess you missed something: openSUSE’s patterns.
Start Yast - Software - Softwaremanager
Go View - Patterns
Check the box left of the LAMP server pattern. All packages needed will be installed.
Next start Yast - System - Services, enable and start mysql
Next Yast - Networkservices - HTTP server. Make it start en open ports in the firewall. Adjust configs or leave default first.
Navigating to 127.0.0.1 should give “It works!”.

Thanks Knurpht, but it hasn’t helped. I’d already got as far as ‘it works’ successfully. I’d added the “web and LAMP server” pattern already, though this did not install all of the packages within (mainly the PostgreSQL stuff, but also a couple of the PHP extensions). I added in the lot and turned on MySQL in Service Manager for completeness, but no change.

The apache2 server is clearly running - it just trying to download PHP files rather than execute them?

Stuart

First: php files are not executable, never. You open them in a browser, they interact with the webserver (which should have php compiled in, installing the LAMP server takes care of all that), or you use some commandline tool to process them.

In the root folder of your webserver, mostly /srv/www/htdocs :
remove / rename index.html (it contains the “It works!” html)
create a file “testphp.php” containing:


<?php
$msg = "Seeing this means php is working";
echo $msg;
?>

then use a browser and navigate to localhost/testphp

If you don’t see the $msg string displayed, check the settings in Yast - Networkservices - HTTP server, first screen after clicking “Next”. “Enable PHP scripting” should be enabled.

If you put in files manually in the webroot, make sure their permission are: wwwrun as the owner, www for the group.

One remark: I can’t see what other things you’ve done/added, so unless you tell exactly what you’ve done I can only state how the defaults should work.

I can’t explain why, but it’s decided to start working!

I originally installed just the default packages in the “web and LAMP server” pattern, but was getting the problem of the browser trying to download when I went to localhost/~stuart/index.php. After adding the extra line to /etc/apache2/mod_userdir.conf and restarting the server as the tutorial suggested, there was no change.

After I posted here, I re-checked the “web and LAMP server” pattern and installed all of the packages in there and also enabled MySQL in Services Manager - again no change, even after restarting the server (and the computer).

I put the php script in “/srv/www/htdocs” as you suggested and it worked! Tried the same script in /home/stuart/public_html and this time it worked!

As far as I know I followed the tutorial exactly (or as exactly as I could considering I’m running OpenSUSE 13.2 and the tutorial is for 11.1), and the only non-default change made was to add the line to /etc/apache2/mod_userdir.conf as described in the tutorial.

Colour me confused (but happy that it’s working).

Thanks

Stuart

Nice to hear you’ve got it working now
It looks like you were both missing some package(s) and forgot to tell us everything. By default the webserver uses /srv/www/htdocs. Yast can be used to configure differently.