0

I have installed Magento 2.4.2 in ubuntu, but after the installation process when I run the front and backend URL, it's not working properly,

I have installed Magento 2.4.2 using the command line.

PHP 7.4 version,

enter image description here

enter image description here

please help me with this issue, I have tried everything possible ways but it's not resolved yet. thanks.

2
  • Check module rewrite enabled or not.
    – Amit Saini
    Mar 3, 2021 at 10:16
  • open 404 error link in new tab and remove "verson161476..." slug and check it's working in new tab or not Mar 3, 2021 at 11:42

7 Answers 7

2

Run below commands :

  1. sudo php bin/magento setup:static-content:deploy
  2. sudo php bin/magento c:c
3
  • i have run all command 3 times but no changes are done.
    – rocky9310
    Mar 3, 2021 at 10:02
  • even i checked permission also, all persmissions are correct
    – rocky9310
    Mar 3, 2021 at 10:03
  • Try sudo php bin/magento setup:upgrade sudo php bin/magento c:f Mar 3, 2021 at 10:05
0

Try to run below commands:

sudo php bin/magento sampledata:reset
sudo php bin/magento setup:upgrade
sudo php bin/magento cache:flush
0

Ensure that your webserver document root is configured correctly. It should be serving Magento from magento_root_folder/pub.

For more information see the following official documentation:

https://devdocs.magento.com/guides/v2.4/install-gde/tutorials/change-docroot-to-pub.html

0
  1. symlink

Create symlink of pub/media and pub/static directory in root.

ln -s /{path}/pub/media /{path}/media

ln -s /{path}/pub/static /{path}/static

example:

ln -s /var/www/html/m242/pub/media /var/www/html/m242/media

ln -s /var/www/html/m242/pub/static /var/www/html/m242/static

2
  • don't remove .htaccess file from pub/static Folder. Mar 10, 2021 at 12:36
  • No, there is no need to remove .htaccess file from pub/static Folder. Mar 11, 2021 at 4:57
0

set base url in core_config_data in magento db -

UPDATE core_config_data SET value='http://localhost/magento242/pub/' WHERE path='web/unsecure/base_url';

This works for me.

0

It seems now Magento will only load from pub folder. By default it will not be possible to load it from the root of Magento.

So the best solution for this is to create a virtual host and point it to pub directory.

Alternative

Meanwhile, as an alternative to run this on local machine I tried something else that seems to be working fine with the default setup. Like earlier we were using the base_url as http://127.0.0.1/magento. So instead of this now we need to use http://127.0.0.1/magento/pub as the base_url. Secure and Unsecure URL needs to be setup on the basis of this.

Setting this up will avoid the issue of 404 page coming.

Note: Verified this with the default Magento only. Not sure for the projects having much complex functionalities. But you can give this a try.

We have another option without adding /pub follow below steps

1. Copy .httaccess file from pub folder and override it to root .htaccess file

2. Upload pub/index.php file to root magento directory

3. Add below code in app/etc/env.php file

'system' => [
    'default' => [
        'web' => [
            'unsecure' => [
                'base_media_url' => '{{secure_base_url}}pub/media/',
                'base_static_url' => '{{secure_base_url}}pub/static/'
            ],
            'secure' => [
                'base_media_url' => '{{secure_base_url}}pub/media/',
                'base_static_url' => '{{secure_base_url}}pub/static/'
            ]
        ]
    ]
],
0

You need to run commands for it. First upgrade command and then deploy.

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

It will generate the symlinks and you will see the proper ui of magento.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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