How to install Magento 2.4.5 on localhost with and without sample data
-
Can you please tell us that your magento 2.4.5 is running fine or not. I want to use Magento 2.4.5 for my site?– Rana ZainOct 21, 2022 at 13:03
-
@RanaZain , It is working fine and also it have some additional features as well, The only problem I have arrived that is Magento 2.4.5 use php 8.1 so some old extensions giving errors of depracated functionality like strpos(), explode(), implode() etc to i have to apply empty checks on these kind of functions otherwis everything is working fine !!– Syed Hassan ZamirOct 24, 2022 at 4:40
-
You upgraded from 2.4 to 2.4.5?. Actually I have the extensions develop on the 2.4.4, so how much we have to work on the 2.4.5?– Rana ZainOct 25, 2022 at 7:55
2 Answers
You may consider to have problems with displaying category views as Elasticsearch or Opensearch is required.
As a workaround you can install local Elasticsearch or better us use the free period at elastic.co
After you have set up your cluster commands look like:
cd ~/home/www/magento2/
install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
check PHP Module / Version
php -m
php -r 'phpinfo(INFO_MODULES);'
php -V
check PHP Memory (2G)
php -i | grep "memory_limit"
check mysdql
mysql -V
create a db in MysQL
install magento
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.5
bin/magento setup:install
--cleanup-database
--base-url-secure=https://magento2.local
--base-url=https://magento2.local
--db-host=localhost
--db-name=magento2
--db-user=m2
--db-password='xxxxxx'
--admin-firstname=John
--admin-lastname=Foo
[email protected]
--admin-user=Admin
--admin-password=demo2022
--use-rewrites=1
--use-secure=1
--language=de_DE
--currency=EUR
--timezone=Europe/Berlin
--elasticsearch-host=https://foo.es.eu-west-1.aws.found.io
--elasticsearch-port=9243
--elasticsearch-enable-auth=true
--elasticsearch-username=elastic
--elasticsearch-password='xxxxxx'
Run after install
bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy -f
bin/magento cache:flush bin/magento indexer:reindex
disable 2-Way aut
bin/magento module:disable Magento_TwoFactorAuth bin/magento cache:flush
Magento 2.4 must have Elastic - else Caterory dont show products
bin/magento setup:install --enable-modules=Magento_InventoryElasticsearch,Magento_Elasticsearch7,Magento_Elasticsearch6,Magento_Elasticsearch
FYI: you may evaluate MAMP Pro. It saves you hours of time.
Good Luck
Andy
Step 1
Visit the Link and download Magento 2.4.5 Click Here
Step 2
Go to the magento root folder, open terminal and paste the following command
php -d memory_limit=-1 bin/magento setup:install \
--base-url="http://localhost/m245/" \
--db-host="127.0.0.1" \
--db-name="m245" \
--db-user="root" \
--db-password="root" \
--admin-firstname="admin" \
--admin-lastname="admin" \
--admin-email="[email protected]" \
--admin-user="admin" \
--admin-password="admin123" \
--language="en_US" \
--currency="USD" \
--timezone="America/Chicago" \
--use-rewrites="1" \
--backend-frontname="admin" \
--elasticsearch-host="127.0.0.1:9201"
Step 3 Now run Magento Commands
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento cache:clean
sudo chmod -R 777 .
now hit the url in the browser http://localhost/m245/pub/
If your's CSS and JS not loaded maybe this is the issue of having incomplete base url to resolve this go to the database and search for the table core_config_data now find the path like web/unsecure/base_url change it's value to http://localhost/m245/pub now flush the cache and reload the broswer your magento will be installed successfully.
If you want to install Sample Data run the following Command
bin/magento sampledata:deploy
for getting access keys follow the link Get your Authentication Keys
Now run below commands again
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento cache:clean
sudo chmod -R 777 .
After these steps Magento will be installed successfully with Sample Data as well.