How to Install Magento 2.4.6 in Ubuntu 22.04

Today I am going to show you how you can install Magento Latest version 2.4.6 in ubuntu 22.04

First of all I am assuming you have setup LAMP in your ubuntu system. If not please do so.

Now please install composer , use below steps to do so.

curl -sS http://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Check with composer -v , If composer is installed or not , It should show you output as below

install composer

Now go to your /var/www/html folder and run below command

composer create-project --repository-url=https://repo.magento.com/  magento/project-community-edition <your-magento2-directory>

It will ask you for magento 2 keys

Just Login to your https://marketplace.magento.com/ and get your key as shown below

magento2 repo key

Once you enter keys , after some time it throw you below errors

Error while installing Magento 2.4.6

Then install the required php extensions

and then again try above command

Now go to your magento directory and give below permissions

find . -type f -exec chmod 644 {} \;            
find . -type d -exec chmod 755 {} \;        
chmod -Rf 777 var
chmod -Rf 777 pub/static
chmod -Rf 777 pub/media
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod -Rf 775 bin

Now install ElasticSearch Using below command

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
apt update
apt install elasticsearch

Now Enable elastic service

systemctl start elasticsearch
systemctl enable elasticsearch

Now we will disable the elasticsearch password

sudo nano /etc/elasticsearch/elasticsearch.yml

Change below to false

# Enable security features 
xpack.security.enabled: false

Now restart the elasticsearch

systemctl restart elasticsearch.service

Check elasticsearch using below command

curl -X GET "localhost:9200/"
elastic-search

If it shows above result means elasticsearch is installed successfully

Now you can run below command to install Magento 2

php bin/magento setup:install --base-url=http://local.freshmagento2.com --db-host=localhost --db-name=magento2 --db-user=root --db-password=Root@123 --admin-firstname=Admin --admin-lastname=User --admin-email=hitesh@createswowtech.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

After installation Done you will see your admin route as below

Magento 2.4.6 installation

Now Setup virtual Host

Go to /etc/apache2/site-available directory

Now create a file like local.freshmagento2.com.conf and paste below code

<VirtualHost *:80>
         
        ServerName local.freshmagento2.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/magento2/pub
 
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


       <Directory /var/www/html/magento2/pub/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
</Directory> 
</VirtualHost>

Save it and run below command

a2ensite local.freshmagento2.com
systemctl restart apache2

Now add host entry in /etc/hosts

127.0.0.1 local.freshmagento2.com

Now when you open http://local.freshmagento2.com you might see “Internal Server Error” Issue

You need to enable mod rewrite using below command

a2enmod rewrite
systemctl restart apache2

Now open http://local.freshmagento2.com you will see below result

Magento 2.4.6 Installation final stage

Hope you like my this topic , Please share with your friends and keep visiting

Leave a Reply
Your email address will not be published. *