Leap 42.1 PHP only executes from HTDOCS dir

OK, another one for the gurus please. I have a SUSE leap 42.2 server, setup with LAMP. Web server is working, but I run 2 domains websites on this server, and they have sub directories off the HTDOCS dir. The server does work for php files from the htdocs dir, I have made a info.php test file. However, when I move that info.php file to htdocs/test, for example, it no longer executes, it downloads. How can I fix it so it executes from the two sub-directories??

Thanks
Matt

You’ll laugh about this later, but are you working in the future? Leap is at 42.1, not 42.2. :wink:

As you do not post the configurations you used for both directories, we can not compare them and ppoint to differences that might be important.

Also the ownership and the permissions on the different directories (and/or files injside) may differ, thus that the process owner of the http processes (nornaly wwwrun) can not access them.

Sorry about the typo. I’m new to this platform, and at this point I’m trying to FIND the config for the directories concerned. It must be in there somewhere, as if I make a new Dir, PHP files work fine.

I do find the config files difficult to follow - too many placed to look. I started with Httpd.conf but it calls quite a few other files. Going thru them all now, must be in there somewhere…

Still not getting anywhere.
Here are the contents of the config files;

Httpd.conf
Include /etc/apache2/uid.conf
Include /etc/apache2/server-tuning.conf
ErrorLog /var/log/apache2/error_log
<IfDefine !SYSCONFIG>
Include /etc/apache2/loadmodule.conf
</IfDefine>
Include /etc/apache2/listen.conf
Include /etc/apache2/mod_log_config.conf
<IfDefine !SYSCONFIG>
Include /etc/apache2/global.conf
</IfDefine>
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf
Include /etc/apache2/mod_reqtimeout.conf
Include /etc/apache2/mod_cgid-timeout.conf
Include /etc/apache2/mod_usertrack.conf
Include /etc/apache2/mod_autoindex-defaults.conf
TypesConfig /etc/apache2/mime.types
Include /etc/apache2/mod_mime-defaults.conf
Include /etc/apache2/errors.conf
Include /etc/apache2/ssl-global.conf
<Directory />
Options None
AllowOverride None
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order deny,allow
allow from all
</IfModule>
</Directory>
AccessFileName .htaccess
<Files ~ “^.ht”>
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
allow from all
</IfModule>
</Files>
DirectoryIndex index.html index.php index.html.var default.html default.htm
Include /etc/apache2/default-server.conf
IncludeOptional /etc/apache2/vhosts.d/*.conf

**
Ip-Based_Vhosts.conf**
<VirtualHost *>
DocumentRoot “/srv/www/htdocs”
<Directory “/srv/www/htdocs”>

Options None

AllowOverride None
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
Require all granted
</Directory>
Alias /icons/ “/usr/share/apache2/icons/”
<Directory “/usr/share/apache2/icons”>
Options Indexes MultiViews
AllowOverride None
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
ScriptAlias /cgi-bin/ “/srv/www/cgi-bin/”
<Directory “/srv/www/cgi-bin”>
AllowOverride None
Options +ExecCGI -Includes
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
<IfModule mod_userdir.c>

Include /etc/apache2/mod_userdir.conf
</IfModule>

IncludeOptional /etc/apache2/conf.d/*.conf
IncludeOptional /etc/apache2/conf.d/apache2-manual?conf
ServerName NGSVR1.neptunes-gear.com
ServerAdmin root@NGSVR1
</VirtualHost>
<VirtualHost *>
DocumentRoot /srv/www/htdocs/paulins
ServerName www.paulins.net
ServerAdmin matt@neptunes-gear.com
<Directory /srv/www/htdocs/paulins>
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /srv/www/htdocs/neptunes-gear
ServerName www.neptunes-gear.com
ServerAdmin matt@neptunes-gear.com
<Directory /srv/www/htdocs/neptunes-gear>
AllowOverride None
Require all granted
</Directory>
</VirtualHost>

and PHP5.conf

<IfModule mod_php5.c>

   &lt;FilesMatch "\.ph(p[345]?|tml)$"&gt;

       SetHandler application/x-httpd-php

   &lt;/FilesMatch&gt;

   &lt;FilesMatch "\.php[345]?s$"&gt;

       SetHandler application/x-httpd-php-source

   &lt;/FilesMatch&gt;

    DirectoryIndex index.php4

    DirectoryIndex index.php5

    DirectoryIndex index.php

</IfModule>

Would anything else help?

It is just the Virtualhost websites that don’t work… Oh and there are no .htaccess files in the virtualhost dirs…

A bit more info.

I have found that this works http:\localhost\info.php but this downloads the file http:\www.domain.com\info.php even though they point to the same location??? Running out of ideas here :(…

I general request:

Please in the future use CODE tags around copied/pasted computer text in a post. It is the # button in the tool bar of the post editor. When applicable copy/paste complete, that is including the prompt, the command, the output and the next prompt.

Thank for posting the configs. There are several [Direectory] definitions there. I repeat th suggestion tocheck their ownership and permissions. Specialy of those that “don’t work” of course. Thus

ls -l <of-those>

I’m not that up on configuration but I’ve just tried using your httpd.conf and vhosts file (and assumed php5.conf is unchanged from installation). I’ve used, eg. test.php in paulins folder.

<?php
echo "hello from paulins";
?>

http://www.paulins.net/test.php produces the expected output in Firefox.

thanks Henk, will do. the LS-l produces the same output for the dirs and files that work as the ones that dont.

Jon, that is interesting. Just to be clear, you have a leap 42.1 server, and put in my httpd and vhosts, and it worked in your test dir? That is progress of a sort - means im looking in the wrong place! must be a different conf file then. the only change i have made to php.ini is to turn short tags on.

ill copy the info.php to my paulins.net dir - the site is live - and not real important, so you can see the issue on the live server.

any other suggestions?

To late to edit the above. That Paulins.net website is down from my current location at least, and I won’t be back in the office til tomorrow. Sorry.
Matt

Apache 2.4 on leap 42.1. I replaced my existing httpd.conf with yours and put your vhosts.conf into the vhosts.d folder. There were no other vhosts. I created the folders “paulins” and “neptunes-gear” under “htdocs” and added the php scripts. I added your domains to my local host file, restarted Apache and things “just worked”.

As suggested, just double check your new directores and php files to make certain they are readable by apache - default user is wwwrun.

Check the logs to see if they give any hints.

Here’s a part of my vhost file


<VirtualHost *>
 DocumentRoot /srv/www/htdocs/knurpht.nl/
 ServerName www.knurpht.nl
 ServerAlias www.knurpht.nl knurpht.nl
 ServerAdmin xxxxxxx . at . xxxxx
 <Directory /srv/www/htdocs/knurpht.nl/>
  AllowOverride All
  Require all granted
 </Directory>
 ScriptAlias /cgi-bin/ /srv/www/cgi-bin
 <Directory /srv/www/cgi-bin>
  AllowOverride None
  Options +ExecCGI -Includes
  Require all granted
 </Directory>
</VirtualHost>

The best advice I ever got re. webserver: Use Yast.
And make sure that folders and their content have wwwrun:www as owner:group.

Well, thanks guys, it’s fixed - but I still don’t know why it was broken. All I did this morning was to go into YAST, open http sever, save the default server as the default, click finish. It restarted the apache service and now it goes…
I’d really like to know what changed, but after wasting so much time on this I need to move on…

Thanks to those who took the time to help.

Cheers
Matt