Cant get index.php to run

Installing Apache2 … following this receipe https://en.opensuse.org/SDB:LAMP_setup

It says:

To verify that php is properly working, create a index.php file into the /srv/www/htdocs/ folder with the following content:

<?php 
phpinfo();
?> 

and point your browser to '[localhost/index.php](http://localhost/index.php)'. You should see a page containing a table with all php settings displayed.

… but when i follow that instruction the index.php file just gets downloaded to my Downloads directory.

I take it that means php has not been installed???

Although i followed instructions closely … i was a bit surprised at the response to ‘a2enmod php7’

which was

(20:24 root@fssd-OS422 griadooss) > a2enmod php7
sed: -e expression #1, char 1: unknown command: `

I think something has gone amiss here?? :frowning:

Clues anybody??

Thanks

Please show


a2enmod -l

And, FWIW: I find you root prompt very confusing, due to missing # at the end.
Did you install the LAMP server pattern? Did you use YaST’s HTTP server module to set things up, or did you do a manual setup?

Thanks … here is the listing … i imagine it should show php somewhere there, is it that right???

Installation? I am following the ‘How To’ setup at SDB:LAMP setup - openSUSE Wiki … i guess that is manual?

The prompt … hmmm … i dont take much notice of it … but will have a look at what is happening there … sorry for the confusion.

(23:13 root@fssd-OS422 griadooss) > a2enmod -l
actions alias auth_basic authn_file authz_host authz_groupfile authz_core authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl socache_shmcb userdir reqtimeout


that seems to be missing php indeed. FWIW, here’s the output from my LAMP server ( it has some extra modules, yes )


# a2enmod -l
authz_host actions alias authz_user auth_basic authn_file authz_groupfile autoindex cgi dir env expires include log_config mime negotiation setenvif userdir auth_digest headers proxy proxy_http rewrite ssl vhost_alias version authnz_external authn_core socache_shmcb authz_core **php7** proxy_wstunnel reqtimeout authz_unixgroup pwauth

FWIIW.

I have just started a few days ago getting LAMP going on a Leap 15 (based on what I have running on a 13.1.

I also have the php7 in that list (but I do not know how it got there). As far as I can remember, I just tried the index.php test and it worked.

Thing is that I copied the default-server-conf from one system to the other, but there is no specific php7 statement there. Also I used the YaST module, which has a list of apache modules (also php5), but not php7. To me it looked as if it was all autmagical.

There being reasonable doubt that PHP7 is running in the OP’s system, I am reluctant to go for the simple question: please show the ownership and permissions of your index.php. Because the following the instruction to create it does not mean that it is done correct.

May have nothing to do with your problem, but when PHP is not called by Apache to do it’s job, I expect the contents of the script to be displayed in the browser window. But you say that it was stored in your Dowload directory. That would be rather intrusive >:(

Given the apache changes between 13.1 and Leap 15, and your copying over the defaults, I doubt whether the references are the same.

May have nothing to do with your problem, but when PHP is not called by Apache to do it’s job, I expect the contents of the script to be displayed in the browser window. But you say that it was stored in your Dowload directory. That would be rather intrusive >:(

This simply happens when the php# module is not loaded when apache starts. Apache considers it just being another downloadable file, which by default goes in ~/Downloads

I do not know which references you mean, but the only thing I changed is the access parameters from something like

Order deny,allow
 Deny from all

to the new concept. Not to difficult if you know about it (and I did already for some time).
The big challenge is the PHP to MySQL interface that chahged complete.

Apache only gives it a MIME type. It is the browser that decides if that MIME type is something it can and will display, or something that the user might want to store in a file. The browser then has probably ~/Download as a default place for that, but if is that really something that then happens without the user acknowledging that? Maybe the browser can be configured to store in ~/Downloads without user interaction, but that is not the default IMHO.

BTW I have seen reports here where in a similar cases (PHP files that were not interpreted as such because the PHP module wasn’t loaded) the php script contents was shown by the browser. Probably because Apache send it down with MIMe type text.

Sure … here is the listing at /srv/www/htdocs/
Being owned by root … might be the issue? But i had to be logged on as root to create it … and i did subsequently log on as root and still the php would not run.?

[root@fssd-OS423 htdocs]# ls -al
total 24K
drwxr-xr-x 3 root root 4.0K Oct  6 01:43 **.**
drwxr-xr-x 5 root root 4.0K May 10  2017 **..**
drwxr-xr-x 2 root root 4.0K May 16 23:48 **gif**
-rw-r--r-- 1 root root   58 Oct  5 19:44 index.html
-rw-r--r-- 1 root root   22 Oct  5 19:48 index.php
-rw-r--r-- 1 root root 2.4K Aug  7  2017 info2html.css


index.php contents:

<?php 
phpinfo();
?> 

As long as it is readable for the Apache process, it is OK. And as it is readable by others/world, that is fine.

But, as I indicated, the real problem is why php7 is not loaded by Apache.

You’re right, yet I’d like to see what happens if these files were chowned to wwwrun:www ( I know f.e. Nextcloud doesn’t like it if files don’t have this ownership. Don’t know it this is an apache or Nextcloud thing though.

I do not have them (in /srv/www) owned by root nor by wwwrun but by another user that has www as primary group. They are readable for the group (www) and all is fine(.html, .cgi and .php),

I also have other places (using Alias) in the home directory of other user(s) (not members of www) and as long as those files are world readable, all is fine.

I added php7 to APACHE_MODULES:

erlangen:~ # grep APACHE_MODULES /etc/sysconfig/apache2
# * In the APACHE_MODULES variable, you can use mod_xyz or just xyz syntax.
# APACHE_MODULES="authz_host alias auth dir log_config mime setenvif"
# APACHE_MODULES="authz_host actions alias asis auth autoindex cgi dir imap include log_config mime negotiation setenvif status userdir"
APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_core authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl socache_shmcb userdir reqtimeout  authn_core php7"
erlangen:~ # 
erlangen:~ # cat /srv/www/htdocs/phpinfo.php
<?php
phpinfo();
?>
erlangen:~ #

http://localhost/phpinfo.php does display:

System Linux erlangen 4.18.9-1-default #1 SMP PREEMPT Thu Sep 20 06:37:04 UTC 2018 (67901ec) x86_64
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php7/apache2
Loaded Configuration File /etc/php7/apache2/php.ini

[root@fssd-OS423 htdocs]# chown wwwrun:www index.php
[root@fssd-OS423 htdocs]# ls -al 
total 24K
drwxr-xr-x 3 root   root 4.0K Oct  6 01:43 .
drwxr-xr-x 5 root   root 4.0K May 10  2017 ..
drwxr-xr-x 2 root   root 4.0K May 16 23:48 gif
-rw-r--r-- 1 root   root   58 Oct  5 19:44 index.html
-rw-r--r-- 1 wwwrun www    22 Oct  5 19:48 index.php                                                                                                                                                                 
-rw-r--r-- 1 root   root 2.4K Aug  7  2017 info2html.css               



[root@fssd-OS423 griadooss]# which php
php is /usr/bin/php
php is /usr/bin/X11/php

 

What do you think i should do guys? … i considered downgrading to php5 but unsure how to do that … here is the yast ouput for php search:

[SOLVED]

Sorry guys … did not see 'page# 2"

Yes!! This works!! Thank you so much!