Hello,
I installed NGINX as a reverse proxy for my Apache and when I’m trying to access the web, It starts downloading the index.php file (with no name). I have completely same files as in this tutorial. (Only domain changed). I need help with this.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there @ondrejnovy,

This usually happens due to misconfigured PHP-FPM settings.

Does this also happen if you try to access the Apache service directly on port 8080? For example if you create an info.php file and then access http://your_server_ip:8080/info.php do you get the content PHP info page?

Can you share your Apache Vhost config and the /etc/apache2/mods-enabled/fastcgi.conf file here?

Another thing that I could suggest is also checking your Apache error log:

  • tail -100 /var/log/apache2/error.log

Also, do you have a .htaccess file inside your document root? If so I could suggest temporary disabling it to test if it is causing the issue for you.

Regards,
Bobby

  • Hello,
    when I create info.php file and access it directly via port 8080, it will display, but when I create index.php file and access it directly via Apache service, it will start to download. There are no errors in apache log file.

    My Apache virtualhost config:

    <VirtualHost *:8080>
        ServerName beta.ondrejnovy.dev
        ServerAlias beta.ondrejnovy.cz
        DocumentRoot /var/www/beta.ondrejnovy.dev/public
        <Directory /var/www/beta.ondrejnovy.dev/public>
            AllowOverride All
        </Directory>
    </VirtualHost>
    

    My fastcgi.conf file:

    <IfModule mod_fastcgi.c>
      AddHandler fastcgi-script .fcgi
      FastCgiIpcDir /var/lib/apache2/fastcgi
      AddType application/x-httpd-fastphp .php
      Action application/x-httpd-fastphp /php-fcgi
      Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi
      FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -socket /run/php/php7.4-fpm.sock -pass-header Authorization
      <Directory /usr/lib/cgi-bin>
        Require all granted
      </Directory>
    </IfModule>
    

    And I do not have a .htaccess file.

    Kind regards,
    Ondřej Nový

    • Hi there @ondrejnovy,

      Can you share the output fo the following command as well:

      • sudo apachectl -M

      It will give you a list of all of the enabled Apache modules.

      Also, it is quite unusual that it works with the info.php file and not with your index file. When you create the info php file and visit it via your browser what is the Server API value as shown here:

      PHP Apache fastcgi

      Regards,
      Bobby

      • Hello @bobbyiliev,
        The Server API is equal to FPM/FastCGI.

        The result of apachectl -M:

        coremodule (static)
        so
        module (static)
        watchdogmodule (static)
        http
        module (static)
        logconfigmodule (static)
        logiomodule (static)
        version
        module (static)
        unixdmodule (static)
        access
        compatmodule (shared)
        actions
        module (shared)
        aliasmodule (shared)
        auth
        basicmodule (shared)
        authn
        coremodule (shared)
        authn
        filemodule (shared)
        authz
        coremodule (shared)
        authz
        hostmodule (shared)
        authz
        usermodule (shared)
        autoindex
        module (shared)
        deflatemodule (shared)
        dir
        module (shared)
        envmodule (shared)
        fastcgi
        module (shared)
        filtermodule (shared)
        mime
        module (shared)
        mpmeventmodule (shared)
        negotiationmodule (shared)
        reqtimeout
        module (shared)
        setenvifmodule (shared)
        status
        module (shared)

        Regards,
        Ondřej Nový

Submit an Answer