Welcome to Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy

Guide for Magento 2.4 Installation on Ubuntu Cloud Server AWS EC2

Guide for Installing Magento ver 2.4 on AWS EC2

Launching EC2 for Magento 2.4 on the Amazon Cloud Server

Play Video about Guide for Installing Magento ver 2.4 on AWS EC2​

Step 1: Install Apache2

				
					sudo apt update

				
			
				
					sudo apt install apache2
				
			
				
					sudo apache2ctl -v

				
			
				
					systemctl is-enabled apache2

				
			
				
					sudo apt install mysql-server

				
			
				
					sudo mysql_secure_installation

				
			
				
					sudo mysql

				
			
				
					exit;
				
			
				
					sudo mysql
				
			
				
					ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin123';
				
			
				
					SELECT user,authentication_string,plugin,host FROM mysql.user;

				
			
				
					exit;
				
			
				
					mysql -u root -p

				
			
				
					SELECT user,authentication_string,plugin,host FROM mysql.user;

				
			
				
					CREATE USER 'magento2'@'localhost' IDENTIFIED BY 'admin123';
				
			
				
					ALTER USER 'magento2'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin123';
				
			
				
					GRANT ALL PRIVILEGES ON *.* TO 'magento2'@'localhost' WITH GRANT OPTION;
				
			
				
					SELECT user,authentication_string,plugin,host FROM mysql.user;
				
			
				
					exit;
				
			
				
					mysql -u magento2 -p
				
			
				
					CREATE DATABASE magento2;
				
			
				
					exit;
				
			
				
					sudo apt update
				
			
				
					sudo apt install php7.4 libapache2-mod-php php-mysql
				
			
				
					php -V
				
			
				
					sudo nano /etc/apache2/mods-enabled/dir.conf
				
			
				
					sudo apt install php7.4-mbstring
				
			
				
					sudo phpenmod mbstring

				
			
				
					sudo a2enmod rewrite
				
			
				
					sudo apt install php7.4-bcmath php7.4-intl php7.4-soap php7.4-zip php7.4-gd php7.4-json php7.4-curl php7.4-cli php7.4-xml php7.4-xmlrpc php7.4-gmp php7.4-common
				
			
				
					sudo apt install php74u-pdo php74u-mysqlnd php74u-opcache php74u-xml php74u-gd php74u-devel php74u-mysql php74u-intl php74u-mbstring php74u-bcmath php74u-json php74u-iconv php74u-soap

				
			
				
					sudo systemctl reload apache2
				
			
				
					php -i | grep "Configuration File"
				
			
				
					sudo nano <path_of_php.ini_file>
				
			

This php.in file location on my server

				
					sudo nano /etc/php/7.4/cli/php.ini
				
			
				
					max_execution_time=18000
max_input_time=1800
memory_limit=4G
				
			
				
					sudo systemctl reload apache2
				
			
				
					Install Elasticsearch
				
			
				
					sudo apt install openjdk-16-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
				
			

check local port running

				
					netstat -tunltp
				
			
				
					sudo nano /etc/elasticsearch/elasticsearch.yml


				
			
				
					node.name: "My First Node"
cluster.name: my-application

network.host: 127.0.0.1
http.port: 9200
				
			
				
					sudo nano /etc/elasticsearch/jvm.options
				
			
				
					TimeoutStartSec set to 9000
				
			
				
					$ sudo nano /usr/lib/systemd/system/elasticsearch.service
				
			
				
					sudo systemctl daemon-reload
				
			
				
					sudo systemctl start elasticsearch.service
				
			
				
					curl -X GET 'http://localhost:9200'


				
			

Install Composer

				
					curl -sS https://getcomposer.org/installer -o composer-setup.php
				
			
				
					sudo php composer-setup.php --install-dir=/usr/bin --filename=composer
				
			
				
					composer
				
			

Download and Install Magento2 Download Magento2

				
					cd /var/www/html
				
			
				
					sudo composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
				
			
				
					sudo composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
				
			

Username

				
					38c674c76e15af149111d537a7340ac1
				
			

Password

				
					65edcad8cbaf356b98deb0d722164c53
				
			

Set file permissions

				
					cd /var/www/html/magento2
				
			
				
					sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
				
			
				
					sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
				
			
				
					sudo chown -R root:www-data
				
			
				
					sudo chmod u+x bin/magento
				
			

Install Magento 2

				
					cd /var/www/html/magento2
				
			
				
					php bin/magento setup:install --base-url=http://magento.prafulbhuskute.com --db-host=localhost --db-name=magento2 --db-user=magento2 --db-password=admin123 --admin-firstname=Admin --admin-lastname=Admin --admin-email=admin@admin.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --backend-frontname=admin --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=localhost --elasticsearch-port=9200
				
			

Change DocumentRoot To Pub

				
					sudo nano /etc/apache2/sites-available/000-default.conf
				
			
				
					<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/magento2/pub
         ServerName magento.prafulbhuskute.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html">
AllowOverride all
</Directory>
</VirtualHost>
				
			
				
					sudo systemctl restart apache2
				
			
				
					cd /var/www/html/magento2
				
			
				
					php bin/magento deploy:mode:set production
				
			
				
					php bin/magento cache:flush
				
			
				
					php bin/magento deploy:mode:set developer
				
			
				
					php bin/magento cache:flush
				
			
				
					sudo chmod -R 777 var pub/static generated generated/
				
			
				
					php bin/magento indexer:reindex
				
			
				
					php bin/magento setup:upgrade
				
			
				
					php bin/magento setup:static-content:deploy -f
				
			
				
					php bin/magento cache:flush
				
			

This command will disable Magento 2 Two-Factor Authorization

				
					php bin/magento module:disable Magento_TwoFactorAuth
				
			

SSH/CLI with admin permissions and navigate to the root folder as my folder located to following path

				
					sudo su
				
			
				
					cd /var/www/html/magento2
				
			

Set permissions to the files as follows

				
					find . -type f -exec chmod 644 {} \;
				
			

Set permissions to the directories as follows

				
					find . -type d -exec chmod 755 {} \;
				
			

Set permissions to special directories: as follows (this commands solve your file uploading issue)

				
					find ./var -type d -exec chmod 777 {} \;
				
			
				
					find ./pub/media -type d -exec chmod 777 {} \;
				
			
				
					find ./pub/static -type d -exec chmod 777 {} \;
				
			

Drop your queries

Table of Contents

Have A Project In Mind? Let's Get To Work