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:
- Access Keys for Magento Marketplace: These can be obtained from: Magento Marketplace Access Keys
- SSH Access and Command Line (I prefer using MobaXterm)
- Composer: Minimum 2.2+
- Database Setup: Minimum MariaDB 10.6+ since Magento 2.4.6
- Opensearch: Minimum in version 2.5
- PHP: 8.1 or 8.2
- PHP Extensions: List of required PHP extensions
- 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):
cd httpdocs
2. Download the required Magento files using Composer:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:2.4.6 .
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:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod -Rf 777 var
chmod -Rf 777 pub/static
chmod -Rf 777 pub/media
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod -Rf 775 bin
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
php bin/magento setup:install --base-url=https://your-website-domain.com --db-host=localhost --db-name=magento2 --db-user=magentoadmin --db-password=magentoadmin --admin-firstname=admin --admin-lastname=admin --admin-email=youremail@domain.com --admin-user=admin --admin-password=admin123 --language=de_DE --currency=EUR --timezone=America/Chicago --use-rewrites=1 --search-engine=opensearch --opensearch-host=localhost --opensearch-port=9200 --opensearch-index-prefix=magento2 --opensearch-timeout=15 --opensearch-enable-auth=1 --opensearch-username=admin --opensearch-password=admin123
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.
rm -rf app/etc/env.php var/* generated/*
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:
curl http://localhost:9200 -u admin:yourpassword // -ku instead of -u for insecure connections
Without authentication:
curl http://localhost:9200
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
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;