cancel
Showing results for 
Search instead for 
Did you mean: 

404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

After upgrading from 2.4.1 to 2.4.3 community-edition, I am unable to properly access admin login or the website. All that is displayed is the website 404 error page which is correctly formatted with images and messages that are stored on the database. I am aware of the requirement that everything should be going through/pub folder, this was already set up and working before the upgrade.

There are no errors or relevant messages showing in any of the system / htttpd / nginx logs other than a 404 error indicating that /pub/index.php is not found. However putting echo messages in index.php, it is found and showing the messages.

 

Trying to access the admin login just gives the website 404 error page, no login panel at all.

 

website conf file is set to point to the <website>/pub

nginx.conf set as root $MAGE_ROOT/pub;

database core_config_data - web/secure/base_url is set to <website>/pub/

 

This was all set and working pre upgrade, I understand that version 2.4.2 has a problem with stores setup under subfolders, mine isn't and I don't see why this would stop me from accessing the admin login panel.

Screenshot 2022-08-10 at 12-47-01 404 Not Found 1.png

Any suggestions for what I may be missing here would be most welcome

 

6 REPLIES 6

Re: 404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

Hi @BTaylor351 ,

 

If your virtual host already pointed to /pub directory then no need to add /pub in core_config_data for web/secure/base_url

 

You just need to add website url in web/unsecure/base_url and web/secure/base_url like https://test.com

 

Problem Solved? Accept as solution!

 

Hope it helps!

Thanks

Ankit Jasani

Re: 404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

Gave that a try Ankit, need those to include /pub/. Taking them out gave me the server 404 page as the url no longer had /pub/ in it.

Thanks

Re: 404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

Then there is issue in your virtual host setup.

Your url should point to pub folder directly.

And in core_config_data web/unsecure/base_url and web/secure/base_url should be always without pub like https://xyz.com/

Don't forgot to add slash at the end of URL.

 

If you are not able to resolve virtual host related issues then try below steps:

 

1) copy index.php and .htaccess files from /pub to your magento root folder (into shop folder)

 

2) Find the below line in index.php (from the shop folder)

require _DIR_ . '/../app/bootstrap.php';

and replace it with

require _DIR_ . '/app/bootstrap.php';

 

3) Go to magento 2 database which you recently created and find the table core_config_data

In this table you need to insert/update below rows

Path => Value

a) web/secure/base_static_url => https://xyz.com/pub/static/

b) web/unsecure/base_static_url => https://xyz.com/pub/static/

c) web/secure/base_media_url => https://xyz.com/pub/media/

d) web/unsecure/base_media_url => https://xyz.com/pub/media/

 

Problem solved? Click Accept as Solution!

 

Hope it helps!

Thanks

Ankit Jasani

Re: 404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

Ok, I will look back through the documentation and see where I've gone wrong. It does still puzzle me that I can some areas but not others like getting the 404 error page. I wouldn't think I should get that if my virtual setup is wrong.

Re: 404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

I am still no further forward with this, I am obviously not getting the right combination of settings for my virtual host/nginx/database  etc. I also tried the second option you mentioned Ankit of copying the index/htaccess files and changing the web/secure/base….. settings. This allowed me access to login to admin but without any of the page styling which presumably confirms I have something pointing to the wrong place.

The following is a snapshot of various conf files and such :-

Background –

  • Server is setup using plesk/centos7/PHP 7.4.30/PHP running as FPM application served by nginx
  • Magento is set up in folder /kcmag2
  • Within my virtual host settings
    • Vhost_nginx.conf
      • set $MAGE_ROOT "/var/www/vhosts/<website_name>/httpdocs/kcmag2/pub/";
    • /etc/nginx/conf.d/kcmag2.conf is set with

server {

     listen 80;

     server_name <website_name>;

     set $MAGE_ROOT /var/www/vhosts/<website_name>/httpdocs/kcmag2/pub;

     include /var/www/vhosts/<website_name>/httpdocs/kcmag2/nginx.conf.sample;

 }

  • Nginx.conf.sample is set with
    • root $MAGE_ROOT/pub;            
  • Database settings
    • Web/secure/base_url   -  https:/<website_name>/kcmag2/
    • Web/secure/base_static_url    - null
    • Web/secure/base_media_url  -  null
    • Web/unsecure/ are all set the same
  • Env.php is set up with

    'directories' => [

        'document_root_is_pub' => true

    ]

 

Results from this give the following when accessing either admin or websitetmp88.jpg

Re: 404 errors on index.php after upgrading to 2.4.3 from 2.4.1 community edition

Have managed to get back access to my admin and site by rerunning the following

php bin/magento cache:clean

rm -rf var/cache/*

rm -rf var/page_cache/*

rm -rf generated/code/*

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy -f

 

Using option 2 of Ankit's suggestions, everything is up and running again. It does mean that the site is not running through the more secure path of /pub/. Still need to sort this out.