NextCloud and PHP-FPM as global alias issues

Hi! Today I decided to test my NextCloud installation as a global alias with PHP-FPM. I currently have a working instance of NextCloud as alias on /var/www/cloud directory, using mod_php7, but I wanted to switch to PHP-FPM with no luck at all! jeje.

My current specs are:

  • Ubuntu server 16.04
  • ISPConfig 3.1.6
  • Installed PHP Versions 5.6 - 7.0 and 7.1
  • NextCloud 12.0.0

As I wanted to enable PHP-FPM with PHP 7.0, I created a PHP-FPM config file in /etc/php/7.0/fpm/pool.d with this config:


listen = /var/lib/php7.0-fpm/cloud.sock
listen.owner = www-data = www-data
listen.mode = 0660

user = www-data
group = www-data

pm = dynamic
pm.max_children = 100
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 400

env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

php_admin_value[open_basedir] = /tmp:/dev/urandom:/usr/share/php:/var/www/cloud:/var/www/clients/client1/web2/tmp/phplogs/
php_admin_value[session.save_path] = /var/lib/php/sessions
php_admin_value[upload_tmp_dir] = /tmp
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f"

After which I created an apache conf file in /etc/apache2/conf-available like this:

# cloud default Apache configuration
Alias /cloud /var/www/cloud

<Directory /var/www/cloud>
    Options +FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All
    Require all granted
    Satisfy Any

    <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"

    <IfModule mod_dav.c>
       Dav off

    <IfModule mod_dav_fs.c>
       Dav off

    <IfModule mod_env.c>
        SetEnv HOME /var/www/cloud
        SetEnv HTTP_HOME /var/www/cloud

    <IfModule mpm_itk_module>
        AssignUserId www-data www-data

<IfModule mod_fastcgi.c>
    KeepAlive On
    KeepAliveTimeout 100
    MaxKeepAliveRequests 200

    <Directory /var/www/cloud>
        Require all granted

        <FilesMatch "\.php[345]?$">
            SetHandler php7-fcgi

    <LocationMatch "/cloud/(fpm-ping|fpm-status)">
        HostnameLookups Off    
        SetHandler php7-fcgi-virt
        Action php7-fcgi-virt /php7-fcgi virtual

    Action php7-fcgi /php7-fcgi virtual
    Alias /php7-fcgi /var/www/cloud/php7-fcgi-cloud
    FastCgiExternalServer /var/www/cloud/php7-fcgi-cloud -idle-timeout 300 -socket /var/lib/php7.0-fpm/cloud.sock -pass-header Authorization


<IfModule mod_proxy_fcgi.c>
    <Directory /var/www/cloud>
        <FilesMatch "\.php[345]?$">
            SetHandler "proxy:unix:/var/lib/php7.0-fpm/cloud.sock|fcgi://localhost"

<IfModule mod_ssl.c>
    SSLUseStapling on
    SSLStaplingResponderTimeout 5
    SSLStaplingReturnResponderErrors off
    SSLStaplingCache shmcb:/var/run/ocsp(128000)

This conf was already enabled because I had NextCloud running with this same apache conf file as mod_php7, so I just restarted php7.0-fpm and apache2 and seemed to be ok, no errors on restart…

For testing purposes I created a test.php file with phpinfo(); inside and enabled fpm-ping and fpm-status locations so I can test the thing and the results are as follows:

  • https: //www. testdomain .com/cloud/: It doesn’t work, just keeps loading and never ends. I don’t get any suspicious messages in var/log/apache2/error.log or /var/log/php7.0-fpm.log
  • https: //www. testdomain .com/cloud/test.php: I get a nice PHP info page that states Server API FPM/FastCGI and other wonders that point me that PHP-FPM was successfully enabled
  • https: //www. testdomain .com/cloud/fpm-ping: I get the nice pong message configured in the PHP-FPM cloud.conf file Pong: *** cloud ***
  • https: //www. testdomain .com/cloud/fpm-test: I get the PHP-FPM status test page with some nice info

As you can see, I’m comletely lost here, because it seems to work, but NextCloud keeps loading forever.

I have also tested with this simple chmod.php file, that is actually working on another virtual host of the same server with this code, but here fails, keeps loading for ever as nextcloud:


  function chmodDirectory( $path = '.', $level = 0 ) {
    $ignore = array( 'cgi-bin', '.', '..' ); 
      $dh = @opendir( $path ); 
      while( false !== ( $file = readdir( $dh ) ) ) { // Loop through the directory 
          if( !in_array( $file, $ignore ) ) {
              if( is_dir( "$path/$file" ) ) {
                  chmodDirectory( "$path/$file", ($level+1));
              } else {
                  chmod("$path/$file",0644); // desired permission settings
	      }//if in array 
	closedir( $dh ); 


Thanks in advise!

Apache error log:

[Wed Aug 02 21:12:30.234671 2017] [fastcgi:error] [pid 23385] [client] FastCGI: comm with server “/var/www/cloud/php7-fcgi-cloud” aborted: idle timeout (300 sec)
[Wed Aug 02 21:12:30.234731 2017] [fastcgi:error] [pid 23385] [client] FastCGI: incomplete headers (0 bytes) received from server “/var/www/cloud/php7-fcgi-cloud”

Hi! Stilll I can’t get this to work, any help will be very appreciated

I think you and I are working on relatively similar issues. I am having issues too, and looking at yours I’m seeing maybe adding “+ExecCGI” to your <Directory> options list in your apache configuration