I have been trying to install Magento on Centos 7 with Nginx and Maria Db for the past 2-3 days now but each time I got errors. I have tried several ways and changed Nginx configuration file and tried many possible solutions available on stackoverflow and Magento docs.
I was only able to install it correctly once, but that was giving me server level error i.e. php-fpm security.limit_extensions
. Therefore, I made the necessary changes to Nginx and I am not getting this error anymore. However, now my installation has 404 error on all the CSS and other files. As shown in the image below.
Store Home Page:
Nginx logs are full of errors like:
> 2020/07/05 08:23:45 [error] 8864#8864: *94 open()
> "/var/www/user/pub/static/version1593936946/adminhtml/Magento/backend/en_US/css/styles.css"
> failed (2: No such file or directory), client: x.x.x.x, server:
> www.domain.com, request: "GET
> /pub/static/version1593936946/adminhtml/Magento/backend/en_US/css/styles.css
> HTTP/1.1", host: "www.user.com", referrer:
> "https://www.user.com/index.php/admin_h7r4ak/admin/index/index/key/57fe0e9d24ad111c0afbf63b34a7fd456106047e74662ae8a/"
I have tried to give magento directory permissions with both, `files and & dir as 777' and also as mentioned in Magento docs i.e.
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
But this does not help. I have tried to install with both users i.e. nginx:nginx
and user that i added to nginx group user:nginx
. The result is same, as shown in the above images.
My Nginx.conf file:
server { listen 80; server_name example.com; root /var/www/example; return 301 https://www.example.com$request_uri; } server { listen 80; server_name www.example.com; root /var/www/example; return 301 https://www.example.com$request_uri; } server { listen 443 ssl http2; server_name example.com; keepalive_timeout 70; root /var/www/example; return 301 https://www.example.com$request_uri; gzip on; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot ssl_protocols TLSv1.2; ssl_ciphers EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4:!3DES; ssl_dhparam /etc/nginx/conf.d/dhparam.pem; ssl_prefer_server_ciphers on; ssl_session_tickets off; ssl_session_cache shared:SSL:10m; } server { listen 443 ssl http2; server_name www.example.com; keepalive_timeout 70; gzip on; # modsecurity on; # modsecurity_rules_file /etc/nginx/modsec/main.conf; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot ssl_protocols TLSv1.2; ssl_ciphers EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4:!3DES; ssl_dhparam /etc/nginx/conf.d/dhparam.pem; ssl_prefer_server_ciphers on; ssl_session_tickets off; ssl_session_cache shared:SSL:10m; add_header X-Frame-Options "DENY"; add_header X-Content-Type-Options nosniff; access_log /var/log/nginx/example.access.log; error_log /var/log/nginx/example.error.log; set $MAGE_ROOT /var/www/example; root $MAGE_ROOT/pub; charset UTF-8; autoindex off; location / { root /var/www/example; #try_files $uri $uri/ = /404.html; if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; } try_files $uri $uri/ $uri.html $uri.php?$args; #try_files $uri $uri/ /index.php$is_args$args; index index.php index.html; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains" always; } error_page 404 403 = /errors/404.php; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 = /errors/50x.php; # PHP entry point for update application location ~* ^/update($|/) { root $MAGE_ROOT; index index.php; location ~ ^/update/index.php { fastcgi_split_path_info ^(/update/index.php)(/.+)$; fastcgi_pass php-fpm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } # Deny everything but index.php location ~ ^/update/(?!pub/). { deny all; } location ~ ^/update/pub/ { add_header X-Frame-Options "SAMEORIGIN"; } } location /pub/ { location ~ ^/pub/media/(downloadable|customer|import|custom_options|theme_customization/.*\.xml) { deny all; } alias $MAGE_ROOT/pub/; add_header X-Frame-Options "SAMEORIGIN"; } location /static/ { # Uncomment the following line in production mode # expires max; # Remove signature of the static files that is used to overcome the browser cache location ~ ^/static/version { rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; expires +1y; if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { add_header Cache-Control "no-store"; add_header X-Frame-Options "SAMEORIGIN"; expires off; if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } } if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/ { try_files $uri $uri/ $uri.html $uri.php?$args; location ~ ^/media/theme_customization/.*\.xml { deny all; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { add_header Cache-Control "public"; add_header X-Frame-Options "SAMEORIGIN"; expires +1y; try_files $uri $uri/ $uri.html $uri.php?$args; } location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { add_header Cache-Control "no-store"; add_header X-Frame-Options "SAMEORIGIN"; expires off; try_files $uri $uri/ $uri.html $uri.php?$args; } add_header X-Frame-Options "SAMEORIGIN"; } location /media/customer/ { deny all; } location /media/downloadable/ { deny all; } location /media/import/ { deny all; } location /media/custom_options/ { deny all; } location /errors/ { location ~* \.xml$ { deny all; } } # Deny access to sensitive files location /.user.ini { deny all; } ###################################################################### ###################################################################### # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~* \.php$ { root /var/www/example; fastcgi_pass php-fpm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; } try_files $uri = 404; fastcgi_split_path_info ^(.+\.php)(/.+)$; 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_intercept_errors on; fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; fastcgi_connect_timeout 600s; fastcgi_read_timeout 600s; fastcgi_buffers 1024 4k; include fastcgi_params; } gzip_disable "msie6"; gzip_comp_level 6; gzip_min_length 1100; gzip_buffers 16 8k; gzip_proxied any; gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss image/svg+xml; gzip_vary on; # Banned locations (only reached if the earlier PHP entry point regexes don't match) location ~* (\.php$|\.phtml$|\.htaccess$|\.git) { deny all; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
I have set memory_limit
to 3G
and execution timeout to 18000
. What am I missing here?