Installing Magento 2.4.6 Using Composer on a Plesk Environment (Ubuntu)

This article will guide you through the entire process of installing Magento Open Source using Composer on a Ubuntu Plesk Server (tested this guide on Plesk 18.0.5.1). You will also find solutions to some issues you might face during the installation.

Requirements:

  1. Access Keys for Magento Marketplace: These can be obtained from: Magento Marketplace Access Keys
  2. SSH Access and Command Line (I prefer using MobaXterm)
  3. Composer: Minimum 2.2+
  4. Database Setup: Minimum MariaDB 10.6+ since Magento 2.4.6
  5. Opensearch: Minimum in version 2.5
  6. PHP: 8.1 or 8.2
  7. PHP Extensions: List of required PHP extensions
  8. SSL Certificate (Optional but Recommended)

Installation:

If you meet the requirements mentioned above, let’s start with the installation process.

1. To install Magento 2.4.6 using Composer on a Plesk server, you will need SSH access. The first command we’ll use is to navigate to the httpdocs folder, where we’ll work on the installation (You can skip this step if you are already in the folder where you want to install Magento):

2. Download the required Magento files using Composer:

Do not forget to use the “.” at the end of the command line. The dot represents the current directory (httpdocs).

2.1. Once done, you will be asked to enther the access keys. The public key is your username, and the private key is your password.

3. Set the correct permissions for the generated folders and files:

4. This is the most important step, and it requires that you have already met the requirements mentioned above. You may copy the command below, but please replace the values of: –base-url, –db-name, –db-user, –db-password, –opensearch-host, –opensearch-port, –opensearch-index-prefix (“magento2” by default), –opensearch-enable-auth, –opensearch-username (by default it’s admin), and –opensearch-password

Important: If you don’t use SSL, please use “http://” instead of “https://”

If you need other parameters, you can find the full list along with their descriptions on this link: Commerce Operations Installation Guide – Advanced Parameters

Common issues & fixes:

1. If you get the error “SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘magento2.admin_user’ doesn’t exist”: Remove the created env.php file and try the installation again.

2. If you encounter the error message “Could not validate a connection to OpenSearch. No alive nodes found in your cluster,” it typically indicates that a connection to the database cannot be established. To verify the connectivity, you can use curl. That said, if you do not need authentication for opensearch, remove those parameters “–opensearch-enable-auth=1 –opensearch-username=admin –opensearch-password=admin123” from your installation command line.

Below is an example demonstrating how to test the connection with curl if you are using OpenSearch with authentication:

Without authentication:

3. If you can not access the magento website after installation and you encounter this error in the logs: “Upstream sent too big header while reading response header from upstream”: You may set i.e. those settings for Proxy, Domain -> Hosting & DNS -> Apache / nginx ->Additional nginx directives: image