1

I am facing a rather strange behavior. I have placed a simple phpinfo test script (see below) as index.php in the root directory of my domain. When I open it as www.example.com in the browser, it loads correctly. However, when I open it as www.example.com/index.php the browser offers me to download the file (which then is the script itself), the same happens to all other .php files. Only when implicitly opening index.php as the domain's landing page it works.

index.php:

<?php
phpinfo();

Configuration:
Ubuntu 18.04
Apache 2.4
PHP 7.2

Further, the server (and Apache's configuration) is maintained through Plesk and runs multiple domains, I have root access. All other domains work fine, it's just this single one and I cannot figure out what the problem is as it is configured the same way. Switching to nginx works, however, I want this domain to be served by Apache for other reasons. There is no .htaccess file, the fact that the file is executed when implicitly opened indicates that PHP generally works.

relevant part of httpd.conf for this domain:

                <IfModule mod_fcgid.c>
                        FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/example.com/etc/php.ini
                        FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
                        FcgidMaxRequestLen 134217728
                        FcgidIOTimeout 300
                </IfModule>

                TimeOut 300
                <Directory /var/www/vhosts/example.com>

                        <IfModule mod_fcgid.c>
                                <Files ~ (\.fcgi$)>
                                        SetHandler fcgid-script
                                        Options +ExecCGI
                                </Files>
                        </IfModule>
                        <IfModule mod_fcgid.c>
                                <Files ~ (\.php$)>
                                        SetHandler fcgid-script
                                        FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
                                        Options +ExecCGI
                                </Files>
                        </IfModule>

                        SSLRequireSSL

                        Options -Includes +ExecCGI

                </Directory>
  • "Only when implicitly opening index.php" - "implicitly" is when mod_dir issues an internal subrequest for the document defined in the DirectoryIndex directive. Where/how is this defined? "it is configured the same way" - although it would seem there must be some difference? Or some kind of proxy / client-side caching? – DocRoot May 15 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.