Hi all,
I am new to Magento and i started learning the platform for couple weeks now. I have working installation of Magento on Ubuntu with Apache2 as this seems to be the easiest method i found.
Now i am trying to get this working on CentOS 8 with Nginx.
So i have installed my Nginx and i have php-fpm:remi7.4
I already installed Magento without issues. However when i try to open the main page or admin page i get nothing.
I created /etc/nginx/conf.d/magento.conf with the following content
upstream fastcgi_backend { server unix:/run/php-fpm/magento.sock; } server { listen 80; server_name 172.30.53.125; set $MAGE_ROOT /usr/share/nginx/html/magento2; set $MAGE_DEBUG_SHOW_ARGS 0; set $MAGE_MODE default; include /usr/share/nginx/html/magento2/nginx.conf.sample; }
Also i have created /etc/php-fpm.d/magento.conf with contents
[magento] user = nginx group = nginx listen.owner = nginx listen.group = nginx listen = /run/php-fpm/magento.sock pm = ondemand pm.max_children = 50 pm.process_idle_timeout = 10s pm.max_requests = 500 chdir = /
With this configuration i get HTTP ERROR 500.
If i delete /etc/nginx/conf.d/magento.conf i get Nginx and PHP working again, but i cannot open the Magento main page again. I am looking for advise here.
Solved! Go to Solution.
Update. I found this error in the logs:
[error] 948#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/usr/share/nginx/html/magento2/var/page_cache" is not writable
This indicates that the "/usr/share/nginx/html/magento2/var/page_cache" folder doesn't have permissions.
So i tried
sudo chmod 744 /usr/share/nginx/html/magento2/var/page_cache
And still i get the same error.
Issue fixed. I had to run the commands below:
chcon -R --type httpd_sys_rw_content_t <magento_root>/app/etc chcon -R --type httpd_sys_rw_content_t <magento_root>/var chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/media chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/static chcon -R --type httpd_sys_rw_content_t <magento_root>/generated
And then i had to do
chown 777 <magento_root>
Update. I found this error in the logs:
[error] 948#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/usr/share/nginx/html/magento2/var/page_cache" is not writable
This indicates that the "/usr/share/nginx/html/magento2/var/page_cache" folder doesn't have permissions.
So i tried
sudo chmod 744 /usr/share/nginx/html/magento2/var/page_cache
And still i get the same error.
Issue fixed. I had to run the commands below:
chcon -R --type httpd_sys_rw_content_t <magento_root>/app/etc chcon -R --type httpd_sys_rw_content_t <magento_root>/var chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/media chcon -R --type httpd_sys_rw_content_t <magento_root>/pub/static chcon -R --type httpd_sys_rw_content_t <magento_root>/generated
And then i had to do
chown 777 <magento_root>