If you’ve opted for Magento for your e-commerce store, consider using extensions to customize it efficiently. Check out Mirasvit, a leading developer of Magento extensions, for more information on their products at Mirasvit.

Guide to Installing Magento 2.4.7 on Ubuntu 20.04

Step 1: Updating all packages on Ubuntu

1.1 Ensure Ubuntu is up to date by running:

# sudo apt update
# sudo apt upgrade

Step 2: Installing Apache

2.1 Install Apache web server with:

# sudo apt install apache2

2.2 Start and enable Apache:

# sudo systemctl start apache2
# sudo systemctl enable apache2

2.3 Check Apache’s status:

# sudo systemctl status apache2

Step 3: Installing PHP and Extensions

Install PHP 8.3 and required extensions:

# sudo apt install php php-exif php-bz2 php-bcmath php-intl php-soap php-zip php-curl php-mbstring php-mysql php-gd php-xml

3.2 Verify PHP installation:

# php -v

3.3 Edit PHP settings:

# sudo nano /etc/php/8.3/apache2/php.ini

Adjust the following values:

short_open_tag = On
memory_limit = 512M
upload_max_filesize = 128M
max_execution_time = 3600

Save and exit. Finally, restart Apache:

# sudo systemctl restart apache2

Step 4: Install MySQL and Set Up a Database

4.1 Install MySQL:

# apt install mysql-server

4.2 Check MySQL Service Status:

# systemctl status mysql

4.3 Secure MySQL Installation:

  • Run the security script to set up the necessary security features:

# mysql_secure_installation

  • Set a root password.
  • Remove anonymous users.
  • Disallow remote root login.
  • Remove the test database and access to it.
  • Reload privilege tables.

4.4 Log Into MySQL Shell:

# mysql -u root -p

4.5 Inside the MySQL Shell, Execute the Following Commands to create a new database and user, then grant privileges:

CREATE DATABASE magentodb;
CREATE USER ‘magentouser’@’localhost’ IDENTIFIED BY ‘Str0ngPa$$w0rd’;
GRANT ALL PRIVILEGES ON magentodb.* TO ‘magentouser’@’localhost’;
FLUSH PRIVILEGES;
EXIT;

Step 5: Installing Elasticsearch

Follow these steps to install Elasticsearch:

5.1 Import the GPG key and add the repository:

# 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

5.2 Update the package manager and install Elasticsearch:

# apt update && apt install elasticsearch

5.3 Start and enable the Elasticsearch service:

# systemctl start elasticsearch
# systemctl enable elasticsearch

5.4 Update the Elasticsearch configuration:

# nano /etc/elasticsearch/elasticsearch.yml

5.5 Restart the Elasticsearch service:

# systemctl restart elasticsearch

5.6 Verify the Elasticsearch installation by running:

# curl -X GET “localhost:9200/”

Step 6: Installing Composer

To install Composer, follow these steps:
6.1 Download Composer:

# curl -sS https://getcomposer.org/installer | php

6.2 Move the Composer file and make it executable:

# mv composer.phar /usr/local/bin/composer
# chmod +x /usr/local/bin/composer

6.3 Verify the Composer version:

# composer –-version

You should see output similar to:

Composer version 2.7.2 2024-03-11 17:12:18

Step 7: Install Magento 2.4.7

7.1 Create access keys on Magento Marketplace.

7.2 Download Magento 2.4.7:

# composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.7 /var/www/magento2

7.3 Set permissions and ownership:

# find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
# chown -R www-data:www-data /var/www/magento2
# chmod -R 755 /var/www/magento2

7.4 Install Magento:

# bin/magento setup:install –base-url=http://your-domain.com –db-host=localhost –db-name=magentodb –db-user=magentouser –db-password=’Str0ngPa$$w0rd’ –admin-firstname=Admin –admin-lastname=User –admin-email=admin@your-domain.com –admin-user=admin –admin-password=admin123 –language=en_US –currency=USD –timezone=America/Chicago –use-rewrites=1

Step 8: Configure Apache for Magento 2.4.7

8.1 Create a new VirtualHost file:

# nano /etc/apache2/sites-available/magento2.conf

8.2 Paste the following, replacing “my-unique-store.com” with your domain:

02mUzodiQksR8k-86h4RFKoxye9v4ksBqkNRk2qiMP956BHxWfe4Cz8-wO0Z40qyVwiHDsFBV6bs0uLhbdTfcSh3cv5kqo1S3Unmuh0WOvhcaRz4C5qBLBc3GOe483DSxRkcFwGlyBeZFUZVtuJ45Fc

8.3 Enable rewrite module and site:

# a2enmod rewrite
# a2ensite magento2.conf

8.4 Restart Apache:

# systemctl restart apache2

Step 9: Access Your Magento 2.4.7 Application

You can access your Magento 2.4.7 application: open your web browser and enter your domain: http://my-unique-store.com/ and complete the configuration.

Troubleshooting Common Installation Issues

PHP Compatibility. Confirm PHP version and necessary extensions are installed.

Permission Errors. Ensure correct permissions for Magento directories and files.

Database Connection Problems. Verify MySQL is operational and credentials are accurate.

Missing PHP Extensions. Install any required extensions not present for Magento.

Apache Configuration. Enable mod_rewrite and set AllowOverride All as needed.

Composer Dependency Challenges. Adjust PHP memory limits and review composer.json for compatibility.

Installation Script Failures. Execute the installation script via command line and examine server logs for errors.

For further assistance, Magento’s official forums or documentation offer comprehensive troubleshooting resources.

Magento installation use cases on Ubuntu

E-commerce startups

New businesses looking for a flexible and scalable platform to launch their online business can use Magento to create a customized store with a wide range of functionality.

Migration from other platforms

Companies with an online store on another platform but want to switch to Magento because of its flexibility and extensibility can use Ubuntu as a stable and reliable foundation for Magento.

Development and testing

Developers can set up a local or test environment on Ubuntu to develop new Magento modules or integrate with other systems.

Scaling for large enterprises

Large companies that need to scale their e-commerce capabilities can use Magento on Ubuntu to optimize performance and ensure the high availability of their resources.

Integration with corporate systems

Magento can be integrated with various enterprise systems, such as ERP or CRM, and Ubuntu provides a stable platform for such integrations.

Geographical expansion

Companies planning geographic expansion and needing additional servers can use Ubuntu as a uniform OS for servers in different locations.

Key Takeaways

Extensions Use. Enhance Magento’s functionality with extensions from providers like Mirasvit.

Installation Process. Follow a detailed installation process, including setting up necessary software like Apache, PHP, MySQL, and Elasticsearch.

Configuration. Ensure server settings, such as PHP configurations and database permissions, are optimized for Magento.

Additional Considerations

Security. Implement robust security measures including strong passwords, HTTPS, and regular updates.

Troubleshooting. Be prepared to address common issues like PHP compatibility, permission errors, and database connection problems.

Maintenance. Regular maintenance is essential for performance and security.

Overall, a successful Magento setup on Ubuntu requires detailed attention to installation, security settings, and ongoing system management.

№2

If you’ve opted for Magento for your e-commerce store, consider using extensions to customize it efficiently. Check out https://mirasvit.com/“>Mirasvit, a leading developer of Magento extensions, for more information on their products at Mirasvit.

Installing Magento 2.4.7 on Ubuntu 20.04.

Step 1: System Update

Before installing any packages, update your system to ensure all existing packages are up to date.

sudo apt update
sudo apt upgrade

Step 2: Install Apache Web Server

Apache suites the best as a popular choice for Magento.

sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2

Step 3: Install PHP and Extensions

Magento 2.4.7 requires PHP 7.4. Install PHP and some extensions that are necessary in this regard.

sudo apt install php7.4 php7.4-common php7.4-cli php7.4-bcmath php7.4-curl php7.4-intl php7.4-mbstring php7.4-soap php7.4-xml php7.4-zip php7.4-json php7.4-gd php7.4-mysql

When installation is finished, you can check the PHP version:

php -v

Step 4: Configure PHP Settings

Configure the php.ini file to set the recommended settings for Magento.

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

Make the following changes:

memory_limit = 2G
upload_max_filesize = 128M
max_execution_time = 1800
date.timezone = Your/Timezone

Step 5: Install MySQL

Install MySQL and set up the required database.

sudo apt install mysql-server
sudo mysql_secure_installation

Log in to MySQL to create a database and user for Magento.

sudo mysql -u root -p

In the MySQL shell, run:

CREATE DATABASE magento;
CREATE USER ‘magento_user’@’localhost’ IDENTIFIED BY ‘strong_password_here’;
GRANT ALL PRIVILEGES ON magento.* TO ‘magento_user’@’localhost’;
FLUSH PRIVILEGES;
EXIT;

Step 6: Install Elasticsearch

Magento 2.4.7 requires Elasticsearch. Install it using:

NtD1X2c1W1pxFg-3WJJbbK7CJExVwoNY69uP3qQOwSP28ZKgC2EaiLCadPh8IBDoB6CE6DxPrwsfShiPmC5079k89llXDWJ6hPsMP4n4S_5bsqC2bfiGbhlNqeZQ6VvexITwTsXpzJt0MCr93tin5Xo

Test if Elasticsearch is running:

S0GbTZ5Xau3-WBtxxrjwS6_Z3tlzA5fC89sxEAwZBUzYU-YiNcH2j7z_bBUH4Ib6_eBrigC3yRsm-T3E8aC6ip1cRdFbbWfmeX2xVsTJJmq9JPkq7LcpDqzzBV3d0YVwP9PcJVoEZskChoOVCcQLqSc

Step 7: Download and Install Magento

Download Magento using Composer.

qD5MSNWHtw0xeejVt4-ouYOOovsvEx4viGJuHq31c34fX3XoF0cedcaIYifPHesApY2972F5jNvE0rCw7Wa3oAm8-Sq_yMjhqg22nGhrrzmrM8DVwnytaKxQS1mg05Js48Xm0JmfCqbeTsImEi4KZgE

Install Magento:

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

Set permissions and ownership:

sudo chown -R www-data:www-data /var/www/magento
sudo find /var/www/magento -type f -exec chmod 644 {} \;
sudo find /var/www/magento -type d -exec chmod 755 {} \;

Step 8: Configure Apache for Magento

Create an Apache virtual host for your Magento.

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

Paste this configuration, modifying ServerName to your domain:

ServerAdmin admin@example.com
DocumentRoot /var/www/magento/pub
ServerName example.com

AllowOverride All

Require all granted

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

Enable the site and Apache rewrite module:

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

Step 9: Finalizing Magento Setup

Open your domain (http://my-unique-store.com/) in a web browser and complete the Magento installation using its setup wizard.

Troubleshooting

Permission Issues

Magento needs the right permissions to work with files and folders. If you’re having trouble with file access:

Make sure the web server user (www-data) owns the Magento files:

sudo chown -R www-data:www-data /var/www/magento

Correctly set permissions for directories and files:

sudo find /var/www/magento -type d -exec chmod 755 {} \;
sudo find /var/www/magento -type f -exec chmod 644 {} \;

PHP Configuration Issues

Wrong PHP settings can lead to Magento failures, especially concerning memory limits and execution times.

Ensure your php.ini file has these settings:

memory_limit = 2G
max_execution_time = 1800
upload_max_filesize = 128M
post_max_size = 128M
date.timezone = Your/Timezone

Apply changes by restarting Apache:

sudo systemctl restart apache2

Database Connection Problems

If Magento can’t connect to the database, check:

Database server status

sudo systemctl status mysql

Ensure credentials and database name in your Magento env.php are correct.

Elasticsearch Connectivity Issues

Magento 2.4.7 needs Elasticsearch to work well. If you face problems:

Check if Elasticsearch is running:

sudo systemctl status elasticsearch

Ensure Magento connects to the right Elasticsearch port (usually 9200):

S0GbTZ5Xau3-WBtxxrjwS6_Z3tlzA5fC89sxEAwZBUzYU-YiNcH2j7z_bBUH4Ib6_eBrigC3yRsm-T3E8aC6ip1cRdFbbWfmeX2xVsTJJmq9JPkq7LcpDqzzBV3d0YVwP9PcJVoEZskChoOVCcQLqSc

Apache Configuration Errors

Wrong Apache setups can block access to your Magento site:

Make sure your Apache site config permits overrides and accurately directs to Magento’s pub directory.

Review the .htaccess file in Magento’s root and pub directory for any issues with URL rewriting or access permissions.

Missing PHP Extensions

Magento needs specific PHP extensions. If you see errors about missing extensions:

Install them using:

sudo apt install php7.4-

For example, you might need php7.4-soap, php7.4-bcmath, and php7.4-intl.

Upgrade Issues

When upgrading from previous versions, make sure:

Follow all upgrade steps as per Magento’s documentation.

Clear cache and generated content:

php bin/magento cache: clean
php bin/magento setup: upgrade

Performance Issues

If Magento is slow or unresponsive:

Improve performance by enabling caching in Magento.

Optimize performance further by configuring and optimizing Varnish Cache for Magento.

Magento installation use cases on Ubuntu

E-commerce startups

New businesses need a flexible and scalable platform to launch their online business can use Magento to create a customized store with a wide range of functionality.

Migration from other platforms

Companies with an online store on another platform but want to switch to Magento because of its flexibility and extensibility can use Ubuntu as a stable and reliable foundation for Magento.

Development and testing

Developers can set up a local or test environment on Ubuntu to develop new Magento modules or integrate with other systems.

Scaling for large enterprises

Large companies that need to scale their e-commerce capabilities can use Magento on Ubuntu to optimize performance and ensure the high availability of their resources.

Integration with corporate systems

Magento can be integrated with various enterprise systems, such as ERP or CRM, and Ubuntu provides a stable platform for such integrations.

Geographical expansion

Companies planning geographic expansion and needing additional servers can use Ubuntu as a uniform OS for servers in different locations.

Key Takeaways

Extensions Use. Enhance Magento’s functionality with extensions from providers like Mirasvit.

Installation Process. Follow a detailed installation process, including setting up necessary software like Apache, PHP, MySQL, and Elasticsearch.

Configuration. Ensure server settings, such as PHP configurations and database permissions, are optimized for Magento.

Additional Considerations

Security. Implement robust security measures including strong passwords, HTTPS, and regular updates.

Troubleshooting. Be prepared to address common issues like PHP compatibility, permission errors, and database connection problems.

Maintenance. Regular maintenance is essential for performance and security.

Overall, a successful Magento setup on Ubuntu requires detailed attention to installation, security settings, and ongoing system management.