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
I am really amazed that Magento pushed this to release without documenting it in the release note or "backwards incompatible" changes, but they did. They mention it in the installation notes, as pointed out in Diana's answer, but nowhere else.
There are several bugs filed on github where people share workarounds they are trying. Main one:
https://jokiruiz.com/magento-2/how-to-run-magento-2-from-a-subdirectory/
and obviously the other options is making the change prior to upgrade https://devdocs.magento.com/guides/v2.4/install-gde/tutorials/change-docroot-to-pub.html
attempt #1 subfolder (not visible in url)
For testing purposes I have a test site upgraded to 2.4.2 and managed to find a config that uses a subfolder BUT the subfolder is invisible in the url.
- magento installed in magento2-path subfolder
- site working on www.mywebsite.com
- if magento2-path was visible in url, and therefore set up in the site url-path config or in stylesheets, that must be cleaned out
- www.mywebsite.com/magento2-path will 404
Note 2: to save work this does not have a local copy of the images and uses "static domain" for images so not certain it 100% correct for static files and probably some extra rule needed for pub/static
site-root
.htaccess
magento2-path
.htaccess
pub
.htaccess
the htaccess at the top has
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteCond %{REQUEST_URI} !^/magento2-path/setup/
RewriteCond %{REQUEST_URI} !^/magento2-path/update/
RewriteCond %{REQUEST_URI} !^/magento2-path/dev/
RewriteCond %{REQUEST_URI} !^/magento2-path/pub/
RewriteCond %{REQUEST_URI} !^/magento2-path/
RewriteRule .* /magento2-path/pub/$0 [L]
RewriteCond %{REQUEST_URI} ^/pub/
RewriteRule .* /magento2-path/$0 [L]
DirectoryIndex index.php
the htaccess in magento2-path is modified to (the / in front of pub is removed)
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
the htaccess in pub
is not modified, except to add any special old "migration" rules I had from migration from past modules or pages that are now gone
attempt #2 subfolder (with redirect)
UPDATE: I have found that for a site that used the magento install path in the URL I can make it redirect so the page shows (without that path) only when the folder is renamed to not match the path anymore. Otherwise requests get passed down the stack. You want to make sure your "root level" rewrites are used, not the magento one.
magento was installed in magento2-path subfolder RENAME THIS FOLDER eg tomagento2-folder
site working on www.mywebsite.com
if magento2-path was visible in url, and therefore set up in the site url-path config or in stylesheets, that must be cleaned out
www.mywebsite.com/magento2-path/whatever redirects to www.mywebsite.com/whatever which displays correctly
site-root
.htaccess
magento2-folder2
.htaccess
pub
.htaccess
the htaccess at the top has (note: this is total overkill i'm sure only half the redirects are needed but not got time to clean)
RewriteEngine on
RewriteRule ^/magento2-path/$ / [R=301,L]
RewriteRule ^/magento2-path$ / [R=301,L]
RewriteRule ^magento2-path/$ / [R=301,L]
RewriteRule ^magento2-path$ / [R=301,L]
RewriteCond %{REQUEST_URI} /magento2-path/
RewriteCond %{REQUEST_URI} !^/magento2-path/setup/
RewriteCond %{REQUEST_URI} !^/magento2-path/update/
RewriteCond %{REQUEST_URI} !^/magento2-path/dev/
RewriteCond %{REQUEST_URI} !^/magento2-path/pub/
RewriteRule ^magento2-path(.*) $1 [R=301,L]
RewriteCond %{REQUEST_URI} /alpineshop/
RewriteCond %{REQUEST_URI} !^/magento2-path/setup/
RewriteCond %{REQUEST_URI} !^/magento2-path/update/
RewriteCond %{REQUEST_URI} !^/magento2-path/dev/
RewriteCond %{REQUEST_URI} !^/magento2-path/pub/
RewriteRule ^/magento2-path/(.*) /$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteCond %{REQUEST_URI} !^/magento2-path/setup/
RewriteCond %{REQUEST_URI} !^/magento2-path/update/
RewriteCond %{REQUEST_URI} !^/magento2-path/dev/
RewriteCond %{REQUEST_URI} !^/magento2-path/
RewriteRule .* /magento2-folder/pub/$0 [L]
RewriteCond %{REQUEST_URI} ^/pub/
RewriteRule .* /magento2-path/$0 [L]
DirectoryIndex index.php
the htaccess in magento2-folder and magento2-folder/pub is the same as above
Best Answer
For fixed the issue in your composer.json
Change order
magento/composer-root-update-plugin, magento/product-community-edition
TO
magento/product-community-edition, magento/composer-root-update-plugin
Update Version
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0"
To
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",