Iam new to CentOS, I installed LEMP stack with Virtualmin, and I have a wired problem that when I execute some PHP codes that use modules I added manually like Chilkat or ionecube loader the PHP gives internal server error 500 with an empty screen on the browser, but when I run this file using SSH command
php play.php
it executed correctly and show me the result on the screen so not sure what is the problem maybe NGINX and PHP-CGI? after I installed the LEMP stack manually I installed Virtualmin and there is my NGINX Conf file
server_names_hash_bucket_size 128;
server {
server_name mydomain.com www.mydomain.com;
listen ip;
root /home/mydomain/public_html;
index index.html index.htm index.php;
access_log /var/log/virtualmin/mydomain.com_access_log;
error_log /var/log/virtualmin/mydomain.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/mydomain/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/php-nginx/159588147640444.sock/socket;
}
listen ip:443 default ssl;
ssl_certificate /home/mydomain/ssl.cert;
ssl_certificate_key /home/mydomain/ssl.key;
fastcgi_read_timeout 60;
}
I Solve the problem by using
fastcgi_pass unix:/run/php-fpm/www.sock;
instead of which is added when I setup Virtualmin with LEMP Stack.
fastcgi_pass unix:/var/php-nginx/159588147640444.sock/socket;
I don't know why it work and what is the difference between both of them, is the unix:/var/php-nginx/159588147640444.sock/socket; crashed or something?
and the old one works only with normal PHP pages but it can't execute modules or something like this it gives 500 Error.
the last thing I install LEMP stack first then I add Virtualmin with LEMP stack so maybe I installed 2 PHP version? not sure, I do this so I can use PHP 7.4.8 because Virtualmin LEMP stack comes with PHP 7.2