In this blog let us learn how to do Magento 2 Migration process in Ubuntu
First make sure you have required backups from your Magento 2 instance that you want to migrate.
Install the Required Software in New Server
Step 1: Install Apache2
Apache is available in Ubuntu’s default software repositories. For this reason, we’ll start by updating the local package index for the latest changes. We need to install Apache web server. Connect to your server using ssh protocol with root access and run this command:
sudo apt update
sudo apt update
sudo apt install apache2
Once installed, you can check the installed Apache version with the following command:
sudo apache2ctl –v
To enable auto startup for apache, use this command:
systemctl is-enabled apache2
Step 2: Install MySQL and Create Database for Magento2
sudo apt install mysql-server
mysql –u root –p
Alter User
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘Your_Password’;
Create User
CREATE USER ‘ Your_User’@’localhost’ IDENTIFIED BY ‘ Your_Password ‘;
Permission Option
GRANT ALL PRIVILEGES ON *.* TO
‘Your_User’@’localhost’ WITH GRANT OPTION;
GRANT permission ON database_name TO ‘user’@’localhost’;
Database Creation
CREATEDATABASE database_name;
Step 3: Install PHP and Required Extensions
As a next step, we shall install PHP. Magento 2.4.4 require PHP 7.4, so we need to install php 8.1 Update your APT repositories.
sudo apt update
Install PHP 8.1 and packages with command:
sudo apt install php8.1 libapache2-mod-php php-mysql
verify your PHP version:
php -v
Install and enable mbstring extension
sudo apt install php7.4-mbstring
sudo phpenmod mbstring
Enable the Apache rewrite module
sudo a2enmod rewrite
Install PHP modules for Magento 2.4.4
sudo apt install php8.1-bcmath php8.1-intl php8.1-soap php8.1-zip php8.1-gd php8.1-json php8.1-curl php8.1-cli php8.1-xml php8.1-xmlrpc php8.1-gmp php8.1-common
Reload Apache for the changes
sudo systemctl reload apache2
Configure php settings
sudo nano path of php.ini
max_execution_time=18000
max_input_time=1800
memory_limit=4G
Save the file. Reload Apache2.
sudo systemctl reload apache2
Step 4: Install and Configure Elasticsearch
sudo apt install openjdk-17-jdk
sudo apt install curl
Import the GPG key for Elasticsearch packages using the following command:
sudo apt install curl sudo curl -sSfL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg –no-defaultkeyring –keyring=gnupg-ring:/etc/apt/trusted.gpg.d/magento.gpg –import
Add Elasticsearch repository to the system using the following command:
sudo sh -c ‘echo “deb https://artifacts.elastic.co/packages/7.x/apt stable main” > /etc/apt/sources.list.d/elastic-7.x.list’
Install Elasticsearch packages on the system:
sudo apt update sudo apt install elasticsearch
The following commands Start and enable the Elasticsearch service:
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
Configure Elasticsearch
Editing the main elasticsearch.yml configuration file
sudo nano /etc/elasticsearch/elasticsearch.yml
…
node.name: “My First Node”
cluster.name: my-application
…
…
network.host: 127.0.0.1
http.port: 9200
…
If your server only has 1GB of RAM, you must edit this setting.
…
-Xms256m
-Xmx256m
…
Save and exit the file. Now start Elasticsearch for the first time:
sudo systemctl daemon-reload
sudo systemctl start elasticsearch.service
Testing Elasticsearch
Test this using curl, the command-line tool for client-side URL transfers. To test the service, make a GET request like this:
curl -X GET ‘http://localhost:9200’
Step 5: Install Composer
curl -sS https://getcomposer.org/installer
-o composer-setup.php
sudo php composer-setup.php –install-dir=/usr/bin –filename=composer
Check the composer version.
Composer -V
Composer downgrade & Upgrade command:
composer self-update –1
composer self-update –2
To export database from Old database server using following command
mysqldump –p user –p databasename > backup_filename.sql
Password: Enter Your Password
To Import the database for new DB server for using following command
mysql –p user –p databasename < dbname.sql
Password: Enter Your password
Update the url from DB table
UPDATE core_config_data SET value = ‘https://www.ppppp.com’ WHERE path IN (‘web/secure/base_url’, ‘web/unsecure/base_url’);
To backup the magento files from old server for using zip command
zip –r backupfile_name.zip /var/www/html/filename
Unzip the folder for new server for this command
unzip file.zip destination_folder
Change DocumentRoot To Pub
sudo nano /etc/apache2/sites-available/000-default.conf
…
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/magento2/pub
ServerName www.website.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
…
Restart Apache for the changes
sudo systemctl restart apache2 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
Hit the URL http://www.website.com in the browser
We hope this blog would help you to Migrate Magento 2 easily. If you need any further clarifications or support regarding migration process, request a free quote here or send a mail to info@code5fixer.com