Magento is one of the most popular open-source e-commerce platforms. It is highly flexible, scalable, and feature-rich, making it a top choice for online stores. In this guide, we will walk you through the steps to install Magento with Apache2 and secure it using Let's Encrypt SSL on Ubuntu 20.04. Whether you are hosting your online store on a Windows VPS UK or another VPS hosting platform, Magento provides a robust solution for e-commerce.

Prerequisites

Before starting, ensure you have the following:

  • An Ubuntu 20.04 LTS server, which could be hosted on a UK Windows VPS, Windows Virtual Private Servers, or another Windows VPS Hosting UK solution.
  • A domain name pointed to your server's IP address.
  • Root or sudo privileges on your server.
  • A LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) installed on your server.
  • At least 2 GB of RAM.

Step 1: Update Your System

Before you begin, make sure your system packages are up to date. Run the following commands:

sudo apt update && sudo apt upgrade -y

Step 2: Install Required PHP Extensions

Magento requires several PHP extensions to function properly. Install the necessary extensions by running the following command:

sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-gd php-xml php-mbstring php-intl php-bcmath php-soap php-zip php-json php-common -y

Step 3: Install MySQL and Create a Database

Magento requires a database to store its data. You can use MySQL or MariaDB. Install MySQL with the following command:

sudo apt install mysql-server -y

Secure your MySQL installation:

sudo mysql_secure_installation

Log in to the MySQL console and create a database and user for Magento:

sudo mysql -u root -p
CREATE DATABASE magento;
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 4: Download Magento

Next, download the latest version of Magento from the official website. You can use the following command to download Magento directly to your server:

cd /var/www/html
sudo wget https://magento.com/tech-resources/download

Extract the Magento archive:

sudo tar -zxvf magento.tar.gz

Move the extracted files to the Magento directory:

sudo mv magento /var/www/html/magento

Step 5: Set Correct Permissions

Set the correct permissions for the Magento files and directories:

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

Step 6: Configure Apache for Magento

Create a new Apache virtual host configuration file for Magento:

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

Add the following content, replacing your-domain.com with your actual domain:

<VirtualHost *:80>
    ServerAdmin admin@your-domain.com
    ServerName your-domain.com
    ServerAlias www.your-domain.com
    DocumentRoot /var/www/html/magento

    <Directory /var/www/html/magento/>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/magento_error.log
    CustomLog ${APACHE_LOG_DIR}/magento_access.log combined
</VirtualHost>

Enable the new configuration and the Apache rewrite module:

sudo a2ensite magento.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 7: Install Composer

Magento uses Composer to manage its dependencies. Install Composer by running:

sudo apt install composer -y

Step 8: Install Magento Using Composer

Navigate to the Magento directory and use Composer to install Magento's dependencies:

cd /var/www/html/magento
sudo composer install

Follow the on-screen instructions to complete the installation.

Step 9: Set Up Magento from the Web Installer

Open your web browser and navigate to http://your-domain.com. You will be greeted by Magento’s web installer. Follow the on-screen instructions to complete the installation by entering your database details and configuring your online store.

Step 10: Secure Your Magento Store with Let's Encrypt SSL

To secure your Magento store, install Let's Encrypt SSL using Certbot:

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d your-domain.com -d www.your-domain.com

Certbot will automatically obtain and install an SSL certificate for your domain and configure Apache to redirect HTTP traffic to HTTPS.

Step 11: Verify SSL

After installing the SSL certificate, you can verify that your Magento store is using SSL by navigating to https://your-domain.com. You should see a padlock icon in the browser address bar, indicating that your connection is secure.

Conclusion

By following this guide, you have successfully installed Magento with Apache2 and Let's Encrypt SSL on Ubuntu 20.04 LTS. Whether you're hosting your e-commerce platform on a Windows VPS UK, Windows VPS Italy, or another Windows Virtual Dedicated Server Hosting solution, Magento offers a scalable and flexible e-commerce platform to build your online store.

War diese Antwort hilfreich? 0 Benutzer fanden dies hilfreich (0 Stimmen)