Issue website downloads index.php instead of showing it

Isolde

New Pleskian
Server operating system version
Plesk Obsidian 18.0.71
Plesk version and microupdate number
18.0.71
Hello, after struggling with a 403 Forbidden issue I know can actually approach my site but! It tries to download the index.php instead of showing it! None of my other sites have this issue...
Plesk version Plesk Obsidian 18.0.71 (newest),
PHP 8.3.23 run as FastCGI application served by Apache
enough memory limit and so on
If I put a index.html next to the index.php it will execute the index.html if I go to mySite.nl/index.html but it will try to download index.php if I go to mySite.nl very strange behaviour.

So when I look at the logs I see 2 strange things: my document root points to mySite.nl/pub (where it should) . If I open Filemanager it shows the files for /pub so that is good and all chmods are right (and ownerships too). index.php and index.html both 644 and owned by the user.

but the logs say:
AH01276: Cannot serve directory /var/www/vhosts/mySite.nl/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm,index.shtml) found, and server-generated directory index forbidden by Options directive.
It should "serve" directory /var/www/vhosts/mySite.nl/pub/ and even on that level there is an index.php (it just does an echo "hello world").
Then there is this "Options directive" which I can search high and low on, it will tell me nothing.

It could be the "additional directives for HTTP /HTTPS" in the php apache & nginx settings and I have tried various things there such as:
<IfModule mod_security2.c>
SecResponseBodyLimit 546870912
</IfModule>
<Directory /var/www/vhosts/mySite.nl/pub>
Options +ExecCGI +FollowSymlinks +Indexes
</Directory>
<Directory /var/www/vhosts/mySite.nl>
Options +ExecCGI +FollowSymlinks +Indexes
</Directory>
but it does not matter what I fill in or if I fill in anything at all...
It simply never works and you can go to the site and it will download the index.php endlessly.
I have tried so many settings, tutorials, anything... Thoroughly fed up with Plesk and it's total inabillity to produce errors that can be understood...
 
Hi,

Is PHP support enabled?
1752059821542.png
Usually, the websites are deployed in a subfolder of the webspace, named ``Document root``:
1752059962699.png
1752059989395.png
Code:
/var/www/vhosts/mySite.nl/httpdocs
If your web application is designed to run the website from the pub subfolder, then you should update the Document root to reflect that. Something like ``httpdocs/pub``.
 
yes, php8.3 running. Yes root is pointing to the right place (if I change it to some place else and put a simple index.php there it will download that too and I can see the difference when I open the download: <?php echo "hi from httpdocs"; ?> or <?php echo "hi from pub"; ?> so on and so on).
I have tried moving the site into httpdocs with root pointing to pub (So Document root* [home symbol] / httpdocs/pub) and I have also tried moving everytthing to a httpsdocs as someone suggested. None of these work... the log will just adapt to whatever I have as directory.
 
yes, php8.3 running. Yes root is pointing to the right place (if I change it to some place else and put a simple index.php there it will download that too and I can see the difference when I open the download: <?php echo "hi from httpdocs"; ?> or <?php echo "hi from pub"; ?> so on and so on).
I have tried moving the site into httpdocs with root pointing to pub (So Document root* [home symbol] / httpdocs/pub) and I have also tried moving everytthing to a httpsdocs as someone suggested. None of these work... the log will just adapt to whatever I have as directory.

The other sites (laravel and such) work fine, it is this one (Magento) which seems to download index.php instead of execute it. So something is doing something that I do not understand.

It says at the top: {DOCROOT} for the document root directory of the website. The current value is /var/www/vhosts/mysite.nl/pub. The HTTPS document root directory is the same as for http.
So I don't think it is something to do with the doc root.... :-(
 
and one more thing, if you push the "view the phpinfo page" link, it displays that totally fine. That is php code too...
 
Make sure that index.php is indeed spelled index.php, not 1ndex.php, Index.php, index.PHP or anything similar. Also make sure that your /httpdocs is owned by your webserver user, group psaserv and that it has permissions 0750.
 
I may be new to Plesk, but I have been doing server installations for over 18 years.
I just thought I would give Plesk a try as CPanel is end of life and I did not want to do another DirectAdmin (I do regret that now). As said before, I have uploaded and created quite a few index.php and index.html files and I can (and sadly do) download those all named download or some number with various echo's in them.
I have tried both with httpdocs and without as, with Plesk, you are not limited to a directory named "httpdocs".

But just to show you I have added another subdomain and did the whole thing again (nr 2 today and nr 6 in total) with a totally new subdomain and this time in httpdocs. So here goes:
1752066753050.png
very important to me: the ability to follow symbolic links
1752066841871.png
Additional directives for HTTP / HTTPS (filled in for both, not that it is of any help but someone suggested it...):
<Directory /var/www/vhosts/solsweb.nl/shop.solsweb.nl>
Options +ExecCGI +FollowSymlinks +Indexes
</Directory>
<Directory /var/www/vhosts/solsweb.nl/shop.solsweb.nl/httpdocs/pub>
Options +ExecCGI +FollowSymlinks +Indexes
</Directory>

A couple of Magento specific things in the "Additional nginx directives" (which I do need):

set $MAGE_ROOT "/var/www/vhosts/solsweb.nl/shop.solsweb.nl/httpdocs";
index index.php;
autoindex off;
charset UTF-8;
error_page 404 403 = /errors/404.php;

location /.user.ini {
deny all;
}
.. et etc

php 8.3 and note the green arrow, the doc root seems to point to the right directory:

1752067013386.png
of course lots of extra memory and stuff (all standard stuff for magento by the way).

Just to show the permissions:
1752067532656.png


And this is what I get when I go to the url:
1752067399430.png
as you can see it wants to download another... index.php....

but if I go to index.html (same directory, same permissions etc) I get:
1752067583309.png
which is what I expect.... (the index.html simply says "hello from httpdocs/pub" to show where it is).

So the shop is there... I can see all files and the pub directory and the files in the pub directory, I can run bin/magento and other cli commands but Plesk or something else simply does not want to show the index.php file.

I tried creating a symlink as I would do on my old server but that just made the logs complain about too many levels... and didn't work either.

Here are the 2 last entries of the logs:
1752067924891.png
I hope it clarifies things a bit... This is now installation number 6 so I have tried everything by now....

I am thinking it could be here somehow, in the "Additional nginx directives":
...
location ~/ {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~/pub/ {
location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) {
deny all;
}
alias $MAGE_ROOT/pub/;
add_header X-Frame-Options "SAMEORIGIN";
}
....
In my other server there is no tilde ~ but if I leave it out (so it would be location /... instead of location ~/...) I get the error:
Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/shop.solsweb.nl/conf/vhost_nginx.conf:53nginx: configuration file /etc/nginx/nginx.conf test failed

Now, as said I am new to Plesk, and I have tried looking at that file (it seems fine) and I have also read here :
Input - How to run Magento 2 on Plesk Obsidian 18 without Docker where they write : In Plesk it is recommended to create a custom vhost template.. and I did try that but it did not do anything at all.. and since this page is already dated, it could be that it does not work anymore for magento....

but still that does not explain why Plesk would prefer to download an index.php file instead of showing it....

So... long story...
 
So it turns out that you're inside a Docker container? And that the whole question is about serving a website via Nginx? Is Proxy mode on or off in the web server settings? If it is off and you are serving the site form Nginx, you need to select the Nginx PHP handler instead of the Apache PHP handler in the PHP configuration.
 
No.

What docker container? Where does it mention a docker container? The steps I followed come from a "How to run Magento 2 on Plesk Obsidian 18 without Docker". I am simply trying to run a Magento 2 website. No docker container.
 
Do you have an .htaccess file in place either in your FTP root directory (the /var/www/vhosts/<your domain>/ directory) or your document root directory? Have you tried to remove it temporarily and test whether index.php is addressed correctly without .htaccess file? I also have doubts how the Nginx directives work along with the Apache web server setup used. Have you considered - just for testing - to remove the Nginx directives to see whether then your index.php file is processed correctly? Have you considered to reload he webserver configuration after applying changes to it? Else it might need the reload lag to reload the latest configuration.
 
renamed it to htaccess.txt and renamed the one in httpdocs too to htaccess.txt, doesn't do much (I don't think nginx uses it, apache could...), this is the content:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

as you can see it should (in apache case) send everything over to /pub/index.php....
 
But that will be the problem, because when you set the document root to /shop.solsweb.nl/httpdocs/pub, you'll end up in /shop.solsweb.nl/httpdocs/pub/pub (which is missing and will result in a 404 not found) - if the .htaccess file is lcoated in shop.solsweb.nl/httpdocs.

So from what I've learned here I assume that the files are simply in wrong directories or maybe "wrong" is the wrong word to use. The relation between .htaccess instructions, directories, files and document root directory chosen in the web server setup mismatches. I will not be able to tell where to correct it. I'd normally put all website files into /shop.solsweb.nl, because further subdirectories don't make sense, OR remove that .htaccess file, have the files in /shop.solsweb.nl/httpdocs/pub (why have to additional subdiretories at all?), but then set the document root in the web server to /shop.solsweb.nl/httpdocs/pub, too.

I also have doubts about the Nginx configuration, because
index index.php;
means that Nginx will look for inde.php when in encounters paths without specific file or directory name. But then it will not be able to interpret index.php, because you opted to have .php files run through Apache and not through Nginx. This will either lead to a 404-not-found message or it will display the text content of the .php file instead of executing it. If you want Nginx to handle .php, then you need to select the Nginx PHP handler. But then you must disable proxy mode, too, so that Nginx handles all .php requests.
 
no the httaccess points to httpdocs/pub as it should, simply one directory up. .htaccess is in httpdocs and points to /pub/index.php... but I am getting more and more errors now, since I tried to turn off the proxy mode :-(
599437#0: *12 upstream sent too big header while reading response header from upstreamnginx error
I have had that error yesterday as well....
Maybe Plesk is simply not suitable for this... It's fine for Laravel applications but it is just not ... right for this. Too many issues... too many weird things going on and like yesterday I seem to going from internal error to forbidden to bad gateway and back.... Time to stop... I have spend 3 days and 2 evenings on this, I cannot afford to spend more time on this :-(
 
Back
Top