Search

Guide on How to Install Magento Ubuntu Server 23 - Easy Steps

Welcome to our comprehensive guide on how to install Magento on Ubuntu Server. If you're looking for a flexible and feature-rich e-commerce platform, Magento is the perfect solution. In this guide, we will walk you through the process of installing Magento on your Ubuntu Server, ensuring a smooth and hassle-free installation experience.

Installing Magento on Ubuntu Server can be an efficient and rewarding process, enabling you to set up your e-commerce store quickly and easily. Whether you're a seasoned developer or a beginner, our step-by-step guide will provide you with all the information you need to successfully install Magento on your Ubuntu Server.

By following this installation guide, you'll be able to unleash the power of Magento and start building your online store with confidence. So, let's get started and create a seamless shopping experience for your customers.

Prerequisites for Installing Magento on Ubuntu Server

Before you begin the installation process, make sure you have the following prerequisites in place:

  1. A VPS running Ubuntu 23.04: Ensure that you have a Virtual Private Server (VPS) with Ubuntu 23.04 installed. This will serve as your hosting environment for Magento.
  2. Root SSH access or a user with sudo privileges: You will need root SSH access or a user with sudo privileges to execute commands and perform administrative tasks during the installation process.

Having these prerequisites will ensure a smooth installation and setup of Magento on your Ubuntu Server.

Why are these prerequisites important?

Installing Magento on Ubuntu Server requires a stable and up-to-date hosting environment. Ubuntu 23.04 provides the necessary foundation for running Magento smoothly. Additionally, having root SSH access or a user with sudo privileges gives you the necessary permissions to install packages, configure settings, and manage the server effectively.

Now that you have the prerequisites ready, let's move on to the next section to learn how to log in via SSH and update the system.

Step 1 - Log in via SSH and Update the System

Before proceeding with the installation of Magento on your Ubuntu Server 23.04, the first step is to log in to your server via SSH. Make sure you have the necessary credentials to access your server as a root user or a regular user with sudo privileges.

Once you are logged in, it is important to update your system to ensure that you have the latest versions of all installed packages. This can be done by running the following command:

sudo apt update && sudo apt upgrade -y

This command will update the package lists and upgrade any installed packages to their latest versions. It is crucial to keep your system up to date to ensure stability and security.

Updating Ubuntu Server 23.04

  1. Log in to your server via SSH as a root user or a user with sudo privileges.
  2. Run the command sudo apt update to update the package lists.
  3. Run the command sudo apt upgrade -y to upgrade all installed packages to their latest versions.

Updating Packages on Ubuntu Server

  • Ensure you have SSH access to your Ubuntu Server 23.04.
  • Use the command sudo apt update to update the package lists.
  • Use the command sudo apt upgrade -y to upgrade all installed packages to their latest versions.

Step 2 - Install Apache Web Server

Now that you have updated your Ubuntu Server, it's time to install the Apache web server. Apache is a widely used web server that provides a stable and reliable platform for hosting websites, including Magento. Follow the steps below to install Apache:

  1. Open a terminal and log in to your Ubuntu Server as a user with sudo privileges.
  2. Run the following command to install Apache:

sudo apt-get install apache2

During the installation, you may be prompted to confirm the installation and enter your sudo password. Once the installation is complete, Apache will be up and running on your server.

To verify if the Apache service is running, you can use the following command:

sudo systemctl status apache2

If Apache is running correctly, you will see a "active (running)" status in the output. You can also test if Apache is working by opening a web browser and entering your server's IP address. You should see the default Apache web page.

Configuring Apache for Magento

To ensure compatibility with Magento, you need to make a few configurations to your Apache installation.

  1. Enable the Apache rewrite module by running the following command:

sudo a2enmod rewrite

  1. Create a new virtual host configuration file for your Magento installation. You can use the default Apache configuration file as a template:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/magento.conf

Open the new configuration file using a text editor and make the following changes:

  • Change the ServerName directive to your domain name or server's IP address.
  • Add the following directives inside the <VirtualHost> tags:

DocumentRoot /var/www/html/magento

DirectoryIndex index.php

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Order allow,deny

allow from all

Save the changes and exit the text editor. Then, enable the new virtual host configuration by running the following command:

sudo a2ensite magento.conf

Finally, restart the Apache service to apply the changes:

sudo systemctl restart apache2

Your Apache web server is now installed and configured for Magento. In the next step, we will install PHP and its extensions.

Step 3 - Install PHP and PHP Extensions

To install Magento on your Ubuntu Server, you need to have PHP 8.1 and the required PHP extensions. Here's how you can install them:

  1. Update the package lists for upgrades and new package installations: sudo apt-get update
  2. Install PHP 8.1 and the necessary PHP extensions by running the following command: sudo apt-get install php8.1 php8.1-cli php8.1-common php8.1-curl php8.1-gd php8.1-mbstring php8.1-zip php8.1-intl php8.1-mysql php8.1-bcmath php8.1-soap php8.1-xml
  3. Once the installation is complete, verify the PHP version using the command: php -v

After installing PHP, you need to configure the PHP settings for optimal performance in Magento:

Edit the php.ini configuration file using your preferred text editor:

sudo nano /etc/php/8.1/apache2/php.ini

Make the following changes:

  • Set memory_limit to at least 2G: memory_limit = 2G
  • Set max_execution_time to 1800: max_execution_time = 1800
  • Set upload_max_filesize to 64M: upload_max_filesize = 64M

Save the changes and exit the text editor (press Ctrl+O, then Ctrl+X).

Now that you have PHP 8.1 installed and configured, you're ready to proceed with the next steps of the Magento installation process on your Ubuntu Server.

Step 4 - Install MySQL Server

Now that you have updated the system and installed Apache and PHP, it's time to install MySQL Server. Follow these steps to get started:

  1. Open your terminal and run the following command to install MySQL Server:
  2. During the installation process, you will be prompted to set a root password for MySQL. Make sure to choose a strong password and remember it for future use.
  3. Once the installation is complete, run the following command to secure your MySQL installation:
  4. This command will guide you through a series of prompts to enhance the security of your MySQL server. Follow the instructions and make the necessary configurations.
  5. Next, you need to create a database and a user for your Magento installation. Run the following commands in your terminal:

Once you've completed these steps, you have successfully installed MySQL Server on your Ubuntu server and created a database and user for your Magento installation. It's time to move on to the next step: installing Elasticsearch.

Step 6 - Install Elasticsearch

In this step, you will install Elasticsearch to enable powerful search capabilities for your Magento platform. Follow the instructions below:

Add the GPG Key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Add the Elastic source list:

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

Update the repositories:

sudo apt update

Install Elasticsearch:

sudo apt install elasticsearch

Start and enable the Elasticsearch service:

sudo systemctl start elasticsearch

sudo systemctl enable elasticsearch

Verify the status of Elasticsearch:

sudo systemctl status elasticsearch

Once you have successfully completed this step, Elasticsearch will be up and running on your Ubuntu Server, ready to enhance the search functionality of your Magento e-commerce platform.

Step 7 - Install Composer

To install Composer on your Ubuntu server, follow these simple steps:

  1. Connect to your Ubuntu server via SSH as a root user or a user with sudo privileges.
  2. Update the system by running the following command:
    sudo apt update
  3. Next, install the necessary dependencies by executing the command:
    sudo apt install curl php-cli php-mbstring unzip
  4. Once the dependencies are installed, you can download and install Composer using the following command:
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  5. Verify the integrity of the downloaded file by comparing its SHA-384 hash with the latest hash from the Composer website.
  6. Now, run the installation script by executing the command:
    sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
  7. Finally, check the installed Composer version by running the command:
    composer --version

That's it! You have successfully installed Composer on your Ubuntu server. Now you can use Composer to manage dependencies and install packages for your Magento installation.

Step 8 - Download and Install Magento

Once you have completed all the necessary prerequisites, it's time to download and install Magento 2.4.4 on your Ubuntu Server. Follow these steps to get started:

  1. Open your terminal and navigate to the directory where you want to install Magento.
  2. Run the following command to download Magento using Composer:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .

This command will fetch the latest version of Magento and create a new project in the current directory.

  1. During the installation process, you will be prompted to provide some information:
  • Base URL: Enter the URL where your Magento store will be accessible.
  • Database details: Provide the database host, username, password, and name that you previously set up.
  • Admin credentials: Set the username and password for your Magento admin panel.
  1. After entering all the required information, the installation process will begin.
  2. Once the installation is complete, you can access your Magento store by visiting the base URL you specified during the installation.

Congratulations! You have successfully downloaded and installed Magento on your Ubuntu Server. You can now proceed to the next step to configure Apache for Magento.

Step 10 - Configure Apache for Magento

Now that Magento is installed on your Ubuntu Server 23.04, it's time to configure Apache to ensure smooth operation of your e-commerce platform. Follow these steps to set up your Apache virtual host for Magento:

  1. Create a new Apache virtual host configuration file specifically for your Magento installation.
  2. Inside the virtual host configuration file, specify the necessary configurations such as the server name, document root, and log file locations.
  3. Enable the virtual host by creating a symbolic link to the virtual host configuration file in the Apache "sites-enabled" directory.
  4. Additionally, enable the Apache rewrite module to ensure proper URL rewriting for Magento.
  5. Restart the Apache service to apply the changes: sudo systemctl restart apache2

Sample Apache Virtual Host Configuration for Magento:

<VirtualHost *:80>
 ServerName yourdomain.com
 DocumentRoot /var/www/html/magento
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 <Directory /var/www/html/magento>
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  allow from all
 </Directory>
</VirtualHost>

Make sure to replace "yourdomain.com" with your actual domain name and "/var/www/html/magento" with the correct path to your Magento installation directory.

With Apache properly configured, your Magento e-commerce platform is ready to go! Now you can start customizing your website and adding products to your online store.

Conclusion

Congratulations! You've successfully installed Magento 2.4.4 on your Ubuntu Server 23.04. By following the step-by-step guide, you have completed the installation process and are now ready to enjoy the full potential of your Magento e-commerce platform.

Throughout this installation, you've learned how to set up prerequisites such as having a VPS running Ubuntu 23.04 with SSH access or a regular user with sudo privileges. You've updated your system, installed Apache web server, PHP and its required extensions, MySQL server, Elasticsearch, Composer, and finally downloaded and installed Magento.

By configuring Apache for your Magento installation, creating a virtual host, and enabling the rewrite module, you've ensured that your e-commerce platform is ready to deliver exceptional performance and functionality. Don't forget to restart the Apache service to apply the changes.

Now that you have successfully completed the Magento installation, you are ready to customize and optimize your online store to meet your specific business needs. With its flexible features and powerful capabilities, Magento is the perfect platform to create a seamless and engaging e-commerce experience for your customers. Enjoy exploring the possibilities and watch your online business thrive!

Sys Admin

Sys Admin

I am a Red Hat Certified Engineer (RHCE) and working as an IT Professional since 2012...