Quickly install the latest Magento 2.4.6 with Virtual Host

Quickly install latest magento 2.4.6 with virtualhost

Hello Magento Devs,

So in this quick tutorial, we are going to see how we can install the latest Magento 2.4.6 in quick easy steps.

Let’s get started, follow the steps with me.

While writing this tutorial, the current Magento version is 2.4.6-p1. So we are going to install it on our Ubuntu environment.

System Requirements:

Composer 2

PHP 8.1, or PHP 8.2

Step 1: Jump to your web server root folder (apache2)

in my case, it is /home/jigar_karangiya/htdocs/ it can be anything like /var/www/html depending on your system configurations.

Step 2: Download the latest magento 2 version using composer

For community or open-source versions :

For enterprise or cloud versions use the below command :

If you want to download a specific Magento version refer below command :

In my case,

it will be commerce edition – 2.4.6-p1 and the directory where I want to install my Magento is m246p1:

So the command will look like the below :

When it asks for the authentication keys, enter your open-source or commerce edition keys.

You can grab your access keys from here.

Step 3: Set file permissions

For the development system use the below commands for correct file permissions to generate files on the go.

Step 4: Create a database for our Magento instance

You can run the below command or manually create a database for this Magento instance.

When it will ask for the password, enter your MySQL user password and hit enter.

It will create an empty database where we can store our Magento 2 tables.

Step 5: Create a Virtual Host file to add a custom domain

Using the below steps you can set up a virtual local domain for our Magento instance, from which our Magento will be accessible on the front end.

Declare Apache2 site configuration :

This will create and open the file in edit mode for our Magento 2 configuration and now paste the below content to the editor.

Save the file and we are ok to move ahead.

Now we need to add a host entry to link with this local domain by adding our domain entry to the /etc/hosts file.

The above command will open the file in the editor, paste the below entry and modify as per requirement :

Enable your site and rewrite the mod :

Restart the Apache2 server using the below command to reflect our changes :

Step 6: Install Magento 2

Run the following lines in Command-Line to install your Magento 2 and update as per your requirement:

It will start installing and configuring your Magento instance like below :

Once the installation process is done, we need a few touches to go ahead before using the Magento instance.

Step 7: Switch to Developer Mode

Step 8: Disable Two Factor Authentication

Disable Two Factor Authentication as we are working locally, by running the below command :

Step 9: Install Sample Data (Optional)

You can simply install sample data using the below command :

Step 10: Run the below deployment commands

Congratulations, You are all set !!

Hit the below URL in the browser :


Bonus :

1. If you want to install b2b modules if you have installed the commerce edition you can run the below command :

2. If you want to install cloud meta packages modules if you have installed the commerce edition you can run the below command :

That’s it for this tutorial, We have covered both Magento versions community and commerce editions, and learned how we can configure a virtual host for a custom domain for our Magento instance.

See You in the next blogs!!

Leave a Reply

Your email address will not be published. Required fields are marked *