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.
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
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
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.
Even simple
echo
isn't working.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.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`
Have you tried uninstalling and re-installing PHP?
Empty.
Permissions are correct.
Yes, but didn't work.
Does other PHP versions work normal?
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.
This being tried on ubuntu 16.04 and debian 9. Same issue.
Yes, php5 works well on debian 8.
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.You should try uninstalling Nginx and PHP. Then start the installation afresh or try apache.
Last case scenario install the LEMP stack with centminmod using the betainstaller72.sh
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:
[...]
Replace
include fastcgi_params;
line withinclude fastcgi.conf;
and restart nginx.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.
Yes, html file works.
I did, then tried to run basic phpinfo and still no error log, nothing related to php.
>
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.
Did you check /var/log/php7.2-fpm.log?
I never did have luck going that route on nginx. This solution always works for me:
Oops, sorry...run
chown -R user:user /var/lib/php/session
then.Is the file /var/log/nginx/access.log also empty?
maybe your lets ecncrypt cert is expired
Or selinux is doing its thing.