2

I upgraded Magento 2.4.1-ee to Magento 2.4.2-ee and after that, I execute the command for upgrade and deploy.

Commands run successfully. But, the front URL and admin URL return the 404 page.

How to solve it?

10
  • can you please confirm that your document root settings from app/etc/env.php match those from the webserver level? like both are set to serve the app from 'pub' or the base folder, otherwise, but there isn't a mismatch between the two. – Diana Botean Feb 17 at 14:18
  • Not getting your point. Could you please elaborate more? – Rohan Hapani Feb 17 at 14:19
  • yep, it's about the settings mentioned here: devdocs.magento.com/guides/v2.4/install-gde/tutorials/… where you would serve the Magento requests from the project base folder OR the pub/ folder which is found under the project base folder. – Diana Botean Feb 17 at 14:22
  • If i want to set base url from root instead of pub then, what should I need to change? – Rohan Hapani Feb 17 at 14:28
  • 1
    Thanks !! @DianaBotean I create virtual host for this single instance and now my all magento running properly :) I added solution as answer. – Rohan Hapani Feb 18 at 3:13
8

As @Diana Suggest, I create virtual host to run m2.4.2-ee

For that follow the below steps :

1. Copy .conf file for virtual domain :

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

2. After that, edit your example.com.conf file using this below commad :

sudo nano /etc/apache2/sites-available/example.com.conf

and then, paste the below code :

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName example.com
    ServerAlias example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/m242ee/pub/


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

3. After that, you need to enable site using below command :

sudo a2ensite example.com.conf

4. Then, setup your host file using this command :

sudo nano /etc/hosts

and add 127.0.0.1 example.com line like

127.0.0.1   localhost
127.0.1.1   test-desktop
127.0.0.1   example.com

5. update url in core_config_data table :

UPDATE `core_config_data` SET `value` = 'http://example.com/' WHERE `core_config_data`.`path` = 'web/unsecure/base_url';
UPDATE `core_config_data` SET `value` = 'http://example.com/' WHERE `core_config_data`.`path` = 'web/secure/base_url';
UPDATE `core_config_data` SET `value` = 'http://example.com/' WHERE `core_config_data`.`path` = 'web/unsecure/base_link_url';
UPDATE `core_config_data` SET `value` = 'http://example.com/' WHERE `core_config_data`.`path` = 'web/secure/base_link_url';

6. In last, restart your apache server :

sudo service apache2 restart

Why this type of issue faced?

It's because, everything is running from pub folder in new version. You can check m2.4.2-ee or m2.4.2-ce .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /pub/$0 [L]
DirectoryIndex index.php

There are major difference in new .htaccess and old version .htaccess file. If you replace old version's .htaccess file then, still you can't running proper.

So, Virtual host is only one solution for now. Using this solution, you can run your new m2.4.2 version and also old version of Magento if you have installed already.

Hope, it will useful for you.

Reference : Click Here

3
  • Thanks for the answer. I have a similar issue and posted it here. I am using a linux VM in azure, and I use VM's IP from my machine to access magento. How do I update virtual host conf and host file in that case. – Rohan Dmello Mar 1 at 16:19
  • It is working when the URL is 127.0.0.1/magento2421/pub but not working when the URL is 127.0.0.1/magento2421 – sumeet bajaj Apr 12 at 13:55
  • 1
    Thanks for the solution. it's 100% working and easy to understand. – Jayesh Apr 24 at 6:05
0

I'm adding this to a more visible place so that people understand what was the problem and why you ended up with it:

As discussed over chat, the Magento instance m2.4.2-ee you mentioned in this question is working now by following the instructions regarding requests serving the app from project root of your Magento installation.

But as mentioned in the chat, due to the fact that you are serving multiple instances of Magento without separate virtual hosts, your problem is now the fact that the other instances don't work. I suggest you edit your initial post and add these new details. I still recommend you use separate vhosts for each m2 instance :) Good luck!

I suggest you consider marking this answer as a solution to your question so that the issue can be marked as solved.

2
  • It is working when the URL is 127.0.0.1/magento2421/pub but not working when the URL is 127.0.0.1/magento2421 – sumeet bajaj Apr 12 at 14:41
  • magento 2.4.2 doesn't like installations in subfolders :) or having multiple magento instances in a /var/www/ at the same time. check this, maybe you can find a solution for your problem here magento.stackexchange.com/questions/332400/… – Diana Botean Apr 12 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.