Below is a complete, SEO-friendly tutorial you can publish on your hosting blog.
How to Install Magento Using SSH
Magento, now known as Adobe Commerce, is a powerful e-commerce platform designed for building and managing online stores. Installing Magento through SSH gives you direct access to the server and is especially useful when working with a VPS or dedicated server.
In this guide, we will explain how to install Magento Open Source using SSH on a Linux server.
Note: Magento installation requirements vary by Magento version. Before starting, check the official Adobe Commerce system requirements and use a supported PHP, database, OpenSearch, and Composer version for the Magento release you intend to install.
Prerequisites
Before installing Magento, make sure you have:
- A Linux VPS or dedicated server
- SSH access with sudo privileges
- A domain name pointing to your server
- Apache or Nginx
- MySQL/MariaDB
- PHP with the extensions required by your Magento version
- Composer
- OpenSearch or Elasticsearch, depending on the Magento version
- SSL certificate for production use
- A Magento Marketplace access key
You should also have sufficient server resources. For a production Magento store, a VPS with adequate CPU, RAM, SSD/NVMe storage, and a properly configured database and search service is recommended.
Step 1: Connect to Your Server Using SSH
From Linux, macOS, or Windows Terminal, connect to your server using:
ssh root@SERVER_IP
Replace SERVER_IP with your actual server IP address.
For example:
ssh [email protected]
If SSH uses a custom port:
ssh -p 2222 root@SERVER_IP
After logging in, update the operating system.
Ubuntu/Debian
apt update && apt upgrade -y
AlmaLinux/Rocky Linux
dnf update -y
Step 2: Install Required Packages
Magento requires several server-side components.
On Ubuntu, you can install commonly required packages with:
apt install -y unzip git curl wget nginx mysql-server
PHP packages depend on the Magento version you are installing. For example:
apt install -y php php-cli php-fpm php-mysql php-curl php-gd \
php-intl php-mbstring php-soap php-xml php-zip php-bcmath
Check your PHP version:
php -v
Make sure the PHP version is supported by your specific Magento release.
Step 3: Install Composer
Composer is required to download Magento and manage its PHP dependencies.
Check whether Composer is already installed:
composer --version
If it is not installed, install Composer using the official Composer installation method.
After installation, verify it:
composer --version
You should see the installed Composer version.
Step 4: Configure MySQL
Log in to MySQL:
mysql -u root -p
Create a database:
CREATE DATABASE magento;
Create a database user:
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
Grant the required privileges:
GRANT ALL PRIVILEGES ON magento.* TO 'magento_user'@'localhost';
Apply the changes:
FLUSH PRIVILEGES;
Exit MySQL:
EXIT;
Keep the following information available because you will need it during Magento installation:
- Database name:
magento - Database username:
magento_user - Database password: your database password
Step 5: Create a Directory for Magento
Create a directory for your website:
mkdir -p /var/www/magento
Move into the directory:
cd /var/www/magento
You can also use a directory such as:
/var/www/html
depending on your server configuration.
Step 6: Obtain Magento Access Keys
Magento packages are distributed through Adobe’s Composer repositories.
You generally need Magento Marketplace authentication keys:
- Public Key
- Private Key
Log in to your Adobe/Magento Marketplace account and obtain your access keys.
When Composer asks for authentication, use:
- Username → Public Key
- Password → Private Key
Keep your private key secure and do not publish it.
Step 7: Download Magento Using Composer
Navigate to your Magento directory:
cd /var/www/magento
Create the Magento project with Composer using the package/version appropriate for your installation.
For example:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .
Composer will ask for your Magento authentication credentials if they are not already configured.
The download may take several minutes depending on your server and network connection.
Step 8: Set Magento File Permissions
Magento requires appropriate ownership and permissions.
For a typical Nginx/PHP-FPM setup:
chown -R www-data:www-data /var/www/magento
Then:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
The exact web-server user can differ between distributions and control panels, so verify the user running PHP-FPM before applying ownership commands.
Step 9: Install Magento From the Command Line
Magento includes a command-line installation tool.
Run:
php bin/magento setup:install \
--base-url=https://example.com/ \
--db-host=localhost \
--db-name=magento \
--db-user=magento_user \
--db-password='StrongPasswordHere' \
--admin-firstname=Admin \
--admin-lastname=User \
[email protected] \
--admin-user=admin \
--admin-password='StrongAdminPasswordHere' \
--language=en_US \
--currency=USD \
--timezone=America/New_York \
--use-rewrites=1
Replace:
example.comwith your domainmagentowith your database namemagento_userwith your database usernameStrongPasswordHerewith your database password[email protected]with your email addressStrongAdminPasswordHerewith a strong Magento administrator password- Currency and timezone with the settings appropriate for your store
For an Indian store, for example, you may use:
--currency=INR
--timezone=Asia/Kolkata
Important
Do not copy passwords containing special characters into shell commands without considering shell quoting. Using single quotes around password values can help, but passwords containing a single quote require additional escaping.
Step 10: Check the Magento Installation
After installation, check Magento’s status:
php bin/magento --version
You can also run:
php bin/magento status
Clear and deploy Magento’s cache:
php bin/magento cache:flush
Step 11: Configure Magento Cron Jobs
Magento relies on cron jobs for many background tasks.
Run:
php bin/magento cron:install
Check the configured cron jobs:
crontab -l
You can also manually configure Magento’s cron tasks if required by your server environment.
Step 12: Configure Magento for Production
For a production website, check the current Magento mode:
php bin/magento deploy:mode:show
Set production mode:
php bin/magento deploy:mode:set production
Then deploy static content:
php bin/magento setup:static-content:deploy -f
Clear the cache:
php bin/magento cache:flush
Step 13: Configure OpenSearch/Elasticsearch
Magento requires a supported search engine for catalog search and related functionality.
Depending on your Magento release, configure the supported OpenSearch or Elasticsearch version.
You can check Magento’s current configuration with:
php bin/magento config:show | grep -i search
The exact configuration commands depend on the Magento release and search engine version.
Step 14: Configure Your Web Server
Magento’s document root should point to:
/var/www/magento/pub
Do not normally point the web server directly to:
/var/www/magento
The pub directory is intended to be the publicly accessible web root.
For Nginx, create a server block for your domain and configure PHP-FPM according to the PHP version installed on your server.
After changing the Nginx configuration, test it:
nginx -t
Then reload Nginx:
systemctl reload nginx
Step 15: Enable SSL
For a production Magento store, HTTPS should be enabled.
After installing an SSL certificate, make sure your Magento base URL uses HTTPS:
https://example.com/
You can also configure Magento’s secure URL settings through the CLI or Admin Panel.
Step 16: Access Magento Admin
After installation, Magento displays the Admin URI.
You can retrieve it with:
php bin/magento info:adminuri
The output may look similar to:
Admin URI: /admin_xxxxx
Open the displayed URL in your browser:
https://example.com/admin_xxxxx
Log in using the administrator credentials created during installation.
Useful Magento SSH Commands
Here are some frequently used Magento CLI commands.
Check Magento version
php bin/magento --version
Check Magento mode
php bin/magento deploy:mode:show
Enable maintenance mode
php bin/magento maintenance:enable
Disable maintenance mode
php bin/magento maintenance:disable
Clear cache
php bin/magento cache:flush
Reindex Magento
php bin/magento indexer:reindex
Check indexer status
php bin/magento indexer:status
Display Admin URL
php bin/magento info:adminuri
Check cron configuration
php bin/magento cron:run
Common Magento Installation Problems
1. Composer Authentication Error
If Composer reports an authentication error, verify your Magento Marketplace access keys.
You can configure them with:
composer config --global http-basic.repo.magento.com PUBLIC_KEY PRIVATE_KEY
Replace the values with your actual credentials.
2. PHP Version Error
If Magento reports an unsupported PHP version, check:
php -v
Install and configure a PHP version supported by the Magento release you are installing.
3. Permission Denied
Check the ownership of the Magento directory:
ls -la /var/www/magento
Then correct ownership and permissions according to your web-server/PHP-FPM user.
4. Database Connection Error
Verify your database credentials:
mysql -u magento_user -p magento
If you cannot connect, check the database name, username, password, host, and MySQL/MariaDB service status.
5. 500 Internal Server Error
Check your web-server and PHP-FPM logs.
For Nginx:
tail -f /var/log/nginx/error.log
For PHP-FPM, check the appropriate PHP-FPM log for your installed version.
Magento’s own logs can also be found under:
var/log/
Conclusion
Installing Magento using SSH provides a flexible way to deploy an e-commerce store on a VPS or dedicated server. The basic process involves preparing the server, installing the required PHP and database components, configuring Composer and Magento authentication, downloading Magento, creating the database, running setup:install, and configuring the web server.
For a production Magento store, don’t stop at the installation itself. Configure HTTPS, cron, caching, OpenSearch/Elasticsearch, backups, firewall rules, file permissions, and regular Magento security updates before accepting customers.
Always verify the requirements for the specific Magento version you are installing, because supported PHP versions, database engines, search engines, and other dependencies can change between releases.