Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


[HELP] PHP showing blank page
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

[HELP] PHP showing blank page

TheKillerTheKiller Member
edited July 2018 in Help

Hello,

I have installed LEMP on my server, but php pages are showing blank.

PHP 7.2
NGINX 1.12
MariaDB 10.

This is what I already tried:

Added this in /etc/nginx/fastcgi_params.

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

and

/etc/php/7.2/fpm/pool.d/www.conf have these:

user = user
group = user
listen.owner = user
listen.group = user
listen = 127.0.0.1:9000

Here is server block for the domain:

server {

    listen 80;
    server_name domain.com www.domain.com;
    return 301 https://$server_name$request_uri;
}
server {

    listen 443 ssl spdy;
    ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;

    server_name domain.com www.domain.com;

    root /home/user/domain.com/public/;
    index index.html index.php;

    access_log /home/user/domain.com/logs/access.log;
    error_log /home/user/domain.com/logs/error.log;

    location / {

        try_files $uri $uri/ /index.php?$args;
    }


    location ~ /.well-known {

        allow all;
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
            expires 365d;
        }location ~*  \.(pdf)$ {
            expires 30d;
    }

    location ~ \.php$ {

        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

And here is nginx config:

user user;
worker_processes 1;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 1024;
    multi_accept on;
}

http {

` ##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 64m;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_dhparam /etc/ssl/dhparams.pem;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;

gzip_vary on;
# gzip_proxied any;
gzip_comp_level 2;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 444;
}

}`

What am I doing wrong? Can you please suggest a solution?

Comments

  • MikePTMikePT Moderator, Patron Provider, Veteran

    The config seems to be ok, though " return 444;" what's that doing there? :|

    Have you tried to enable debugging? Have you tried the basic echo to test it?

  • Display all PHP errors, have a look at the access logs too.

  • likely php memory_limit is small and script is taking more memory.

  • @BecomeWebHost said:
    likely php memory_limit is small and script is taking more memory.

    Even simple echo isn't working.

    Thanked by 1BecomeWebHost
  • HBAndreiHBAndrei Member, Top Host, Host Rep

    Have you tried connecting it via socket? You should have some errors in /var/log/nginx/error.log which could help you debug where the issue is.

  • MikePTMikePT Moderator, Patron Provider, Veteran

    It could be php-fpm, so check the logs for fpm as well. Though Andrei's advice is a good one, if it's not able to connect to fpm it'll be displayed in error.log.

  • Check /var/lib/nginx and /var/lib/php permission it seems you use abid as nginx user`

  • WebsecWebsec Member

    Have you tried uninstalling and re-installing PHP?

  • @HBAndrei said:
    Have you tried connecting it via socket? You should have some errors in /var/log/nginx/error.log which could help you debug where the issue is.

    Empty.

    @robohost said:
    Check /var/lib/nginx and /var/lib/php permission it seems you use abid as nginx user`

    Permissions are correct.

    @Websec said:
    Have you tried uninstalling and re-installing PHP?

    Yes, but didn't work.

  • WebsecWebsec Member

    Does other PHP versions work normal?

  • MikePTMikePT Moderator, Patron Provider, Veteran

    @TheKiller said:

    @HBAndrei said:
    Have you tried connecting it via socket? You should have some errors in /var/log/nginx/error.log which could help you debug where the issue is.

    Empty.

    @robohost said:
    Check /var/lib/nginx and /var/lib/php permission it seems you use abid as nginx user`

    Permissions are correct.

    @Websec said:
    Have you tried uninstalling and re-installing PHP?

    Yes, but didn't work.

    If you want, I'd be glad to have a look and get it sorted. Seems to be a nice challenge. We're certainly missing something in the config, or could be something else.

    Make sure its loading the php handler as well.

  • @Websec said:
    Does other PHP versions work normal?

    This being tried on ubuntu 16.04 and debian 9. Same issue.

    Yes, php5 works well on debian 8.

  • HBAndreiHBAndrei Member, Top Host, Host Rep

    Try un-commenting ;listen.allowed_clients = 127.0.0.1 in /etc/php/7.2/fpm/pool.d/www.conf and then restart php-fpm. I know that according to the documentation it shouldn't matter, but if I recall correctly, some time ago this fixed a similar issue one of my servers... so maybe it's worth a shot.

  • WebsecWebsec Member

    @TheKiller said:

    @Websec said:
    Does other PHP versions work normal?

    This being tried on ubuntu 16.04 and debian 9. Same issue.

    Yes, php5 works well on debian 8.

    You should try uninstalling Nginx and PHP. Then start the installation afresh or try apache.

    Thanked by 1TheKiller
  • vovlervovler Member

    Last case scenario install the LEMP stack with centminmod using the betainstaller72.sh

  • vmp32kvmp32k Member
    edited July 2018

    Try removing the default_server statement from the other server block, I'm almost certain you're running in to the same pitfall I almost always do:
    nginx has a very peculiar order in which it processes requests, generally it is "the more specific your listen block is, the higher the priority" and default_server trumps all.

    https://www.digitalocean.com/community/tutorials/understanding-nginx-server-and-location-block-selection-algorithms:

    Nginx then attempts to collect a list of the server blocks that match the request most specifically based on the IP address and port. This means that any block that is functionally using 0.0.0.0 as its IP address (to match any interface), will not be selected if there are matching blocks that list a specific IP address. In any case, the port must be matched exactly.

    [...]

    Each IP address/port combo has a default server block that will be used when a course of action can not be determined with the above methods. For an IP address/port combo, this will either be the first block in the configuration or the block that contains the default_server option as part of the listen directive (which would override the first-found algorithm). There can be only one default_server declaration per each IP address/port combination.

  • UmutUmut Member

    Replace include fastcgi_params; line with include fastcgi.conf; and restart nginx.

  • EvpaEvpa Member
    1. Did you add in /etc/nginx/sites-available/ symlink to domain configuration file?
    2. Try to open in browser any html file in your domain's directory. Does it work?
  • terrahostterrahost Member, Patron Provider

    Check PHP-FPM error logs.

    By default FPM does not log errors. Open /etc/php/7.2/fpm/pool.d/www.conf and change catch_workers_output from no to yes.

  • @Evpa said:
    1. Did you add in /etc/nginx/sites-available/ symlink to domain configuration file?
    2. Try to open in browser any html file in your domain's directory. Does it work?

    Yes, html file works.

  • @terrahost said:
    Check PHP-FPM error logs.

    By default FPM does not log errors. Open /etc/php/7.2/fpm/pool.d/www.conf and change catch_workers_output from no to yes.

    I did, then tried to run basic phpinfo and still no error log, nothing related to php.

  • @TheKiller said:
    Hello,

    I have installed LEMP on my server, but php pages are showing blank.

    >

    It could be due to permission issue on PHP session folder. Please run this.


    chown -R nginx:nginx /var/lib/php/session

    Hope this help. :)

  • EvpaEvpa Member
    edited July 2018

    @ShweHost said:
    It could be due to permission issue on PHP session folder. Please run this.


    chown -R nginx:nginx /var/lib/php/session

    Hope this help. :)

    Pay attention that topicstarter runs nginx from 'user' user.

    @TheKiller said:
    I did, then tried to run basic phpinfo and still no error log, nothing related to php.

    Did you check /var/log/php7.2-fpm.log?

  • thagoatthagoat Member
    edited July 2018

    [TheKiller said]

    location ~ .php$ {
    try_files $uri =404;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    I never did have luck going that route on nginx. This solution always works for me:

    location ~ \.php$ {
        try_files $uri $uri/ =404;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    Thanked by 1simonindia
  • @Evpa said:

    Pay attention that topicstarter runs nginx from 'user' user.

    Oops, sorry...run chown -R user:user /var/lib/php/session then.

  • Is the file /var/log/nginx/access.log also empty?

  • jcalebjcaleb Member

    maybe your lets ecncrypt cert is expired

  • zkyezzkyez Member

    Or selinux is doing its thing.

Sign In or Register to comment.