How to Install Magento 2.4.6 on Ubuntu

September 15, 2023
How to Install Magento 2.4.6 on Ubuntu

How to Install Magento 2.4.6 on Ubuntu

Prerequisites

  • An Ubuntu server
  • SSH access to the server
  • Root or sudo access

Step 1: Update the System Packages

Before installing Magento, it is recommended to update the system packages to their latest versions. Run the following commands:

$ sudo apt update
$ sudo apt upgrade

Step 2: Install Apache Web Server

Magento requires a web server to run. Install Apache using the following command:

$ sudo apt install apache2

Step 3: Install MySQL Database Server

Magento also requires a database server to store its data. Install MySQL using the following command:

$ sudo apt install mysql-server

Step 4: Install PHP and Required Extensions

Magento is built using PHP, so you need to install PHP and some required extensions. Run the following commands:

$ sudo apt install php libapache2-mod-php php-mysql php-common php-cli php-curl php-gd php-intl php-mbstring php-xml php-zip

Step 5: Download and Extract Magento

Download the latest version of Magento from the official website. Once downloaded, extract the files to the Apache web server's root directory. You can use the following commands as an example:

$ wget https://magento.com/download
$ tar -xvf Magento-CE-2.4.6.tar.gz -C /var/www/html/

Step 6: Set Appropriate Permissions

Set the appropriate permissions for Magento to run smoothly. Run the following commands:

$ sudo chown -R www-data:www-data /var/www/html/
$ sudo chmod -R 755 /var/www/html/

Step 7: Configure Apache

Configure Apache to serve the Magento website. Create a new virtual host configuration file using a text editor:

$ sudo nano /etc/apache2/sites-available/magento.conf

Inside the file, add the following content:

ServerName your-domain.com
DocumentRoot /var/www/html/

    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted

Save the file and enable the virtual host:

$ sudo a2ensite magento.conf

Finally, restart Apache for the changes to take effect:

$ sudo systemctl restart apache2

Step 8: Install Magento

Open a web browser and navigate to your server's domain or IP address. Follow the on-screen instructions to complete the Magento installation process.

Conclusion

You have successfully installed Magento 2.4.6 on Ubuntu. You can now start building your online store using Magento's powerful features.