In this guide, I will be installing Magento 2.4.5 on a cPanel server where ElasticSearch has been installed. Before proceeding to the next step make sure that you are using a supported PHP version and have all required extensions enabled.
- Step 1. Get Private and Public keys
- Step 2. Create a new project
- Step 3. Create a database
- Step 4. Install Magento
Get Private and Public keys
Login to https://marketplace.magento.com/customer/accessKeys/ to get private and public access key:
- Public Key = Username
- Private Key = Password
Create a project
On the server where Magento 2.4.5 will be installed run the following command:
sudo composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.5 magento2
Change file permissions:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R user_name:www-data .
chmod u+x bin/magento
Create a new database
Then create a new Database to be used by Magento.
https://docs.cpanel.net/cpanel/databases/mysql-database-wizard/
Save the database name, username and password for the next step.
Install Magento
After the database has been created run the following to install Magento:
php bin/magento setup:install --base-url=<your-domain> --db-host=localhost --db-name=magento2 --db-user=magento2 --db-password=<your-db-password-of-magento2-user> --admin-firstname=Admin --admin-lastname=Admin --admin-email=admin@admin.com --admin-user=admin --admin-password=<your-admin-password> --language=en_US --currency=USD --timezone=America/Chicago --backend-frontname=admin --search-engine=elasticsearch7 --elasticsearch-host=localhost --elasticsearch-port=9200
Next, you will need to run these commands to upgrade the database and deploy static view files
php bin/magento indexer:reindex && php bin/magento se:up && php bin/magento se:s:d -f && php bin/magento c:f && php bin/magento module:disable Magento_TwoFactorAuth