Expertise over technologies, commitment to deadlines, experienced corporate trainers and more makes us an ideal IT solution provider to your enterprise. Isn’t it the right time to work together?
Install VMware WorkStation 16 Player (Non Commercial)
Install VMware Workstation Player 16 pro for Windows Link:
https://www.vmware.com/go/getplayer-win
Download ubuntu from ubuntu LTS from:
https://ubuntu.com/download/desktop. (Version: 20 .04 LTS)
Create Virtual Machine for Ubuntu. (Video Link):
https://www.youtube.com/watch?v=9rUhGWijf9U
- Disk Capacity: 100 GB
- Memory: 8 GB
- Processor: 4 cores
Step 1: Installing Apache
1 2 |
sudo apt update sudo apt install apache2 |
Enable auto startup for apache
1 |
sudo systemctl is-enabled apache2 |
Checking apache2 Version
1 |
sudo apache2ctl -v |
Step 2: Installing MySQL
1 2 3 4 5 6 7 |
sudo apt update sudo apt install mysql-server sudo mysql SELECT user,authentication_string,plugin,host FROM mysql.user; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_secure_password'; SELECT user,authentication_string,plugin,host FROM mysql.user; exit |
Login with root user.
1 2 3 4 |
mysql -u root -p SELECT user,authentication_string,plugin,host FROM mysql.user; CREATE USER 'magento2'@'localhost' IDENTIFIED BY 'your_secure_password'; ALTER USER 'magento2'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_secure_password'; |
Grant all privileges to magento2 users.
1 2 3 |
GRANT ALL PRIVILEGES ON *.* TO 'magento2'@'localhost' WITH GRANT OPTION; SELECT user,authentication_string,plugin,host FROM mysql.user; exit; |
Create Magento 2 database
1 2 3 |
mysql -u magento2 -p CREATE DATABASE magento2; exit; |
Install PHP 7.4
1 2 3 4 5 6 |
sudo apt-get update sudo apt -y install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt -y install php7.4 sudo apt install php7.4 libapache2-mod-php |
command to open the
dir.conf
file in a text editor with root privileges
1 |
sudo nano /etc/apache2/mods-enabled/dir.conf |
Check Whether to change or not
1 2 |
< IfModule mod_dir.c >DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm< /IfModule > # vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
Check Php Version
1 |
php -v |
Change Php Version (If Php version is not 7.4)
1 2 3 4 5 |
sudo a2dismod php8.1 sudo a2enmod php7.4 sudo update-alternatives --set php /usr/bin/php7.4 sudo update-alternatives --config php php -v |
Install Php Extension
1 |
sudo apt install php7.4-gd php7.4-curl php7.4-intl php7.4-bcmath php7.4-ctype php7.4-dom php7.4-iconv php7.4-mbstring php7.4-simplexml php7.4-soap php7.4-zip php7.4-xsl php7.4-json php7.4-cli php7.4-xml php7.4-xmlrpc php7.4-gmp php7.4-common php7.4-mysql |
Enable Php Rewite Mode
1 |
sudo a2enmod rewrite |
Install ElasticSearch
1 2 3 4 5 |
sudo apt-get install -y openjdk-8-jdk curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list sudo apt update -y sudo apt install elasticsearch -y |
Enable auto startup of Elasticsearch
1 |
sudo systemctl --now enable elasticsearch |
Check If elasticsearch Status
1 |
curl -X GET "localhost:9200" |
If curl is not installed
1 2 |
sudo apt update && sudo apt upgrade sudo apt install curl |
Create Virtual host
1 2 3 |
cd /etc/apache2/sites-available/ sudo cp 000-default.conf magento2.conf sudo nano magento2.conf |
Change and Add below content
1 2 |
DocumentRoot /var/www/html/magento2/pub Servername local.magento.com |
Enable Site
1 |
sudo a2ensite magento2.conf |
Add Virtual host
1 |
sudo nano /etc/hosts |
Add below content
1 |
127.0.0.1 local.magento.com |
Reload apache2
1 |
sudo service apache2 reload |
Downloading Composer
Make sure you’re in your home directory, then retrieve the installer using curl:
1 2 |
cd ~ curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php |
Next, we’ll verify that the downloaded installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page
1 |
HASH=`curl -sS https://composer.github.io/installer.sig` |
If you want to verify the obtained value, you can run:
1 |
echo $HASH |
Now execute the following PHP code, as provided in the Composer download page, to verify that the installation script is safe to run:
1 |
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" |
You’ll see the following output:
1 |
Installer verified |
If the output says Installer corrupt
, you’ll need to download the installation script again and double check that you’re using the correct hash. Then, repeat the verification process. When you have a verified installer, you can continue.
To install composer
globally, use the following command which will download and install Composer as a system-wide command named composer
, under /usr/local/bin
:
1 |
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer |
Check composer version
1 |
composer |
If want to use specific composer version then run
1 |
sudo composer self-update <version> |
Change php.ini setting
1 2 |
cd /etc/php/7.4/apache2 sudo nano php.ini |
Change below values
1 2 3 4 5 6 7 |
max_execution_time = 18000 max_input_time = 300 memory_limit = 4096M precision = 14 output_buffering = 4096 zlib.output_compression = On zlib.output_compression_level = -1 |
For New Magento Projects
Go to html folder using
1 |
cd /var/www/html |
Run this to download magento2
1 |
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.3-p2 magento2 |
(Change to version 2.4.3-p2 to version you want to download)
Use username and password as public and private key from magento2 marketplace
After successful composer install goto magento 2 folder by below comand
1 |
cd magento2 |
Run these command to install magento2
1 |
php bin/magento setup:install --base-url=http://local.magento.com --db-host=localhost --db-name=magento2 --db-user=magento2 --db-password=magento@123 --admin-firstname=admin --admin-lastname=admin --admin-email=admin123@admin.com --admin-user=admin --admin-password=Admin@123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --backend-frontname=admin |
After successfully runing magento install command, run the below commands in the root of Project Folder
1 2 3 4 5 6 |
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 indexer:reindex sudo php bin/magento cache:flush sudo chmod -R 777 app/ var/ pub/ generated/ |
Now go to browser
Hit URL: http://local.magento.com – (For frontend)
Hit URL: http://local.magento.com/admin – (For Magento admin)
If admin url shows 404 error
1 |
sudo nano /etc/apache2/apache2.conf |
Modify
1 2 3 4 5 |
< Directory /var/www/ > Options Indexes FollowSymLinks AllowOverride None Require all granted < /Directory > |
To
1 2 3 4 5 |
< Directory /var/www/ > Options Indexes FollowSymLinks AllowOverride All Require all granted < /Directory > |
Restart Apache2
1 |
sudo service apache2 restart |
Run all commands.
Excellent! Saved my lots of time.
2022-06-30 at 11:21 pm