How to install Magento 2.4.5-p1 latest version on LAMP using Composer with the sample data?
3 Answers
Try below setps and check.
- Install
LAMP (Linux, Apache, MySQL, PHP)
on your system if it is not already installed. - Install Composer on your system. You can follow the official documentation for installation instructions.
- Create a new directory for your Magento installation. For example,
you can create a directory called
“magento2”
in your web server root directory. - Navigate to the newly created directory in your terminal and run the following command to install Magento 2.4.5-p1:
Here is the command:-
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.5-p1 magento2
- After done above command run below this command for install sampledata.
Here is the command:-
php bin/magento sampledata:deploy
- Once the sample data is installed, run the following command to install the database:
Here is the command:-
php bin/magento setup:install --base-url=http://<yourdomain.com>/magento2/ --db-host=<your-db-host> --db-name=<your-db-name> --db-user=<your-db-user> --db-password=<your-db-password> --admin-firstname=<your-first-name> --admin-lastname=<your-last-name> --admin-email=<your-email> --admin-user=<your-admin-username> --admin-password=<your-admin-password>
- Replace the values in angle brackets with your own values.
- After the installation is complete, navigate to your domain URL in your web browser to access the Magento 2.4.5-p1 installation.
Let me know if any query.
THANKS.
- You have to create an adobe commerce account.
- You can install it with this. https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/next-steps/sample-data/overview.html?lang=en
If you want to complete guidance for installing Magento latest 2.4.5-p1 version on the LAMP using composer then follow the below steps which work for me.
Step : 1 Magento version-wise system requirement. First, Check the Magento System Requirements on the official site.
Step : 2 Install or Update Composer. Official Composer Site
//Remove the existing or Composer 1 version by using the below commands.
sudo apt-get remove composer
//Install the latest Composer version.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Output :
All settings correct for using Composer
Downloading...
Composer (version 2.5.1) successfully installed to: /home/username/composer.phar
Use it: php composer.phar
//Check the composer version
composer -v
//Diagnose composer issue.
composer diagnose
Step : 3 Remove Or Upgrade existing mysql Version
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo rm -rf /var/lib/mysql
Upgrade Mysql 5.7 to 8.0 Version
Step : 4 Upgrade PHP version from 7.4 To 8.1
//Add PPA for PHP 8.1
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php8.1
sudo a2dismod php7.4
sudo a2enmod php8.1
//Install PHP Extensions
sudo apt install php8.1 libapache2-mod-php8.1 php8.1-common php8.1-gmp php8.1-curl php8.1-soap php8.1-bcmath php8.1-intl php8.1-mbstring php8.1-xmlrpc php8.1-mcrypt php8.1-mysql php8.1-gd php8.1-xml php8.1-cli php8.1-zip
//Check PHP Version
php -v
//If it's still showing the old PHP version then you can run below command and choose the new PHP version from their list. so run bellow command:
sudo update-alternatives --config PHP
//Restart Apache Server
sudo service apache2 restart
Upgrade PHP version from 7.4 To 8.1 check this Reference Link.
Step : 5 Install and configure Elasticsearch
sudo apt install openjdk-17-jdk
java -version
sudo apt install curl
sudo curl -sSfL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --no-default-keyring --keyring=gnupg-ring:/etc/apt/trusted.gpg.d/magento.gpg --import
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
sudo chmod 666 /etc/apt/trusted.gpg.d/magento.gpg
sudo apt update
sudo apt install elasticsearch
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
//Test Elastic Search
curl -X GET 'http://localhost:9200'
Step : 6 Connect to the database through the terminal.
sudo mysql -u yourdbuser -p
User : yourdbuser
Password : yourdbpassword
//Create a new MySQL database user
CREATE USER youruser@localhost IDENTIFIED BY 'user123';
GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'localhost';
FLUSH PRIVILEGES;
Resolved Access denied for user 'root'@'localhost'
Step : 7 Create Virtual Host for new magento project in Apache Web Server.
//Start by copying the file for the first domain:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/magento245p1.com.conf
//Open the new file in your editor (we’re using nano below) with root privileges:
sudo nano /etc/apache2/sites-available/magento245p1.com.conf
//We will customize this file for our own domain. Modify the highlighted text below for your own circumstances.
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName magento245p1.com
ServerAlias www.magento245p1.com
DocumentRoot /var/www/html/magento245p1/pub
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
//Set Up Local Hosts File
sudo nano /etc/hosts
//Add below line
127.0.1.1 magento245p1.com
//Enable the New Virtual Host Files
sudo a2ensite magento245p1.com.conf
//Apache restart
sudo systemctl restart apache2
Step : 8 Install Magento Latest Version 2.4.5-p1 using composer.
//First create magento project folder and replace in the below Magento Create Project command. For example, in my case i have created project folder as magento245p1 in this path (var/www/html/magento245p1).
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento245p1
//Magento folder & file permission.
sudo find . -type f -exec chmod 664 {} \;
sudo find . -type d -exec chmod 775 {} \;
sudo find var pub/static pub/media app/etc -type f -exec chmod g+w {} \;
sudo find var pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
sudo chmod u+x bin/magento
//Magento 2.4.5-p1 configuration. Please change according to your user & database details.
php bin/magento setup:install --base-url="" --db-host="localhost" --db-name="dbname" --db-user="dbuser" --db-password="dbpass" --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"
Step : 9 Install Magento Sample Data by using below command.
php bin/magento sampledata:deploy
Step : 10 Phpmyadmin giving error. resolved by following the reference link.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';