0

I have a concrete5 site that works 'out of the box' in apache server. However I am having a lot of trouble running it in nginx.

The following is the nginx configuration i am using:

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ index.php;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            fastcgi_pass unix:/tmp/phpfpm.sock;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            include fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
}

I am able to get the homepage but am having problem with the inner pages. The inner pages display an "Access denied". Possibly the rewrite is not working, in effect I think its querying and trying to execute php files directly instead of going through the concrete dispatcher.

I am totally lost here.

Thank you for your help, in advance.

1

2 Answers 2

0

Changed the configurations to:

server {
    root /home/test/public;
    index index.php;

    access_log /home/test/logs/access.log;
    error_log /home/test/logs/error.log;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.php/$request_uri;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

    # pass the PHP scripts to FastCGI server listening on unix socket
    #
    location ~ \.php($|/) {
            set $script $uri;
            if ($uri ~ "^(.+\.php)(/.+)") {
                    set $script $1;
            }
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$script;
            fastcgi_intercept_errors on;
            fastcgi_pass unix:/tmp/phpfpm.sock;
    }

    location ~ /\.ht {
            deny  all;
    }
}

And it works thanks to hangover and the link he provided.

I am still not clear what I did wrong, maybe an nginx expert can help me understand.

0

Have a look at the below configuration. It has been used for Debian 8, NGinx with PHP-FPM 7.1 The issues that I had were related with "Access denied" on dashboard (ccm) and several editing blocks that were not working anymore (development has been carried on a Apache 2.4 with PHP 5.6, using mod-apache)

Focus was creating a working "location /" try_files $uri $uri/ /index.php?q=$uri&$args;

server { listen 80; server_name www.example.com; root /var/www/example.com/www;

   index index.php index.html index.htm default.html default.htm;

    add_header Access-Control-Allow-Origin *;
    #add_header X-Frame-Options "ALLOWALL";

   location = /favicon.ico {
            log_not_found off;
            access_log off;
   }

   location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
   }

    location / {
            # try_files $uri $uri/ =404;
            try_files $uri $uri/ /index.php?q=$uri&$args;
    }

location ~ \.php($|/) {
        set $script $uri;
        if ($uri ~ "^(.+\.php)(/.+)") {
                set $script $1;
        }
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$script;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}

}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .