0

I know this question has already been answered mutiple times, but the answers are almost all diffrent and are sorta confusing. I have tried alot of answers but none of them work. I follow the answer of this question (switch apache from prefork to event in Ubuntu 16, get php 7 working) and that worked correctly. But then I did something (cant remember what.. oops) and it broke giving me the following error:

File not found.

Virtual host file:

#ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.2-fpm.sock|fcgi://localhost/var/www/nextcloud/
#ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.2-fpm.sock|fcgi://127.0.0.1:9000


LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so



<IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [[..]]@icloud.com
    ServerName [[..]].me
    ServerAlias www.[[..]].me
    DocumentRoot /var/www/nextcloud
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.[[..]].me/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.[[..]].me/privkey.pem

ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.2-fpm.sock|fcgi://localhost/var/www/nextcloud/

#        <FilesMatch \.php>
#            SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost/var/www/nextcloud/"
#        <FilesMatch>

</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
    ServerAdmin [[..]]@icloud.com
    ServerName [[..]].me
    ServerAlias www.[[..]].me
    DocumentRoot /var/www/nextcloud
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
Redirect permanent / https://[[..]].me/
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
# RewriteCond %{SERVER_NAME} =www.[[..]].me [OR]
# RewriteCond %{SERVER_NAME} =[[..]].me
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
#        <FilesMatch \.php>
#            SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost/"
#        <FilesMatch>

</VirtualHost>
</IfModule>
<Directory /var/www/nextcloud>
         AllowOverride All
</Directory>

Also, I'm a total beginner to PHP. I'm so sorry for asking this question again. I know its a duplicate but I just can't get my hands around it.

Thank you so much!

1 Answers1

0

You haven’t included the php-fpm configuration, which is important. How you define your pool is important (see below).

FastCGI is simply a communication protocol that sends the request to PHP, a FastCGI daemon. That output is the PHP Daemon not being able to find the file that was passed to it.

In the absence of that, the easiest solution is to install strace and attach it to your pool worker (this is easier if you only have 1-2 workers). Watch the paths it attempts to open and then determine if they exist.

Two possible things that I see wrong (or could see wrong) with your configuration.

  1. I see fcgi://localhost/var/www/nextcloud/ which is probably prefixing /var/www/nextcloud to the full path. This is wrong. You should not have a path here in your proxy_path_match. See my configuration example below.

  2. You might be using some of the chroot/prefix parameters in your pool definition in FastCGI. Unfortunately the chroot is broken with php-fpm/apache and has been for many years (bug report: https://bugs.php.net/bug.php?id=62279 ). If you’re using that, turn it off.

With those two fixes, you should be okay.

And for the record, my apache configuration has only ONE stanza related to FastCGI/PHP (as follows). It’s all you need specific to PHP-FPM. In the global scope or within a virtualHost depending on what you prefer.

  <FilesMatch     \.php$>
  <If "-f %{REQUEST_FILENAME}">
    SetHandler      "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost/"
  </If>
  </FilesMatch>
michaelkrieger
  • 200
  • 1
  • 4