Magento 2 is a powerful but heavy shop platform. You can run it on cPanel if the account has SSH or Terminal access, enough memory and a search engine (OpenSearch) to connect to. This guide covers a Magento 2 install on cPanel step by step.
Before you start
- SSH access or cPanel → Advanced → Terminal.
- PHP 8.2 or 8.3 with the extensions
bcmath,ctype,curl,dom,gd,intl,mbstring,openssl,pdo_mysql,soap,sodium,xslandzip. - A
memory_limitof at least 2G for the CLI. - Access to an OpenSearch (or Elasticsearch) server. Magento 2.4 will not install without one, and most shared plans do not include it. If you cannot get one, use a VPS instead: see Magento 2 on a VPS.
- Magento Marketplace access keys (public and private key) from your Adobe Commerce Marketplace account.
Set the PHP version and extensions
- Go to cPanel → Software → Select PHP Version (CloudLinux) or MultiPHP Manager.
- Choose PHP 8.2 or 8.3 for the domain and tick the extensions listed above.
- Under Options, set
memory_limitto 2048M or higher andmax_execution_timeto 1800.
More detail is in select the PHP version and extensions in cPanel.
Create the database
In cPanel → Databases → Manage My Databases, create a database and a user, then add the user to the database with ALL PRIVILEGES. Note the full prefixed names, e.g. cpuser_magento.
Download Magento with Composer
Install into a folder outside public_html, then point the domain's document root at its pub folder:
cd ~ && composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2Enter the Marketplace public key as the username and the private key as the password when asked. If Composer runs out of memory, prefix the command with COMPOSER_MEMORY_LIMIT=-1. Other problems are covered in fix common Composer errors.
Run setup:install
cd ~/magento2 && php bin/magento setup:install --base-url=https://shop.example.com/ --db-host=localhost --db-name=cpuser_magento --db-user=cpuser_mguser --db-password='DbPassword' --admin-firstname=Admin --admin-lastname=User --admin-email=you@example.com --admin-user=admin --admin-password='AdminPass123!' --language=en_US --currency=USD --timezone=UTC --use-rewrites=1 --search-engine=opensearch --opensearch-host=your-opensearch-host --opensearch-port=9200At the end, the installer prints the admin URI, such as /admin_1abc2d. Save it.
Point the domain to the pub folder
In cPanel → Domains, edit the domain's document root to magento2/pub. Serving from pub keeps the app code out of reach of browsers.
Add the Magento cron jobs
php bin/magento cron:installOr add php /home/cpuser/magento2/bin/magento cron:run every minute in cPanel → Advanced → Cron Jobs. Without cron, indexes, emails and scheduled tasks stop working.
Switch to production mode
php bin/magento deploy:mode:set productionThis compiles code and deploys static files. It takes several minutes and a lot of memory.
Troubleshooting
- Could not validate a connection to OpenSearch: the search host is wrong or unreachable from the server.
- Allowed memory size exhausted: raise the CLI memory_limit, or run
php -d memory_limit=-1 bin/magento …. - Unstyled pages: static files were not deployed. Run
php bin/magento setup:static-content:deploy -f.
For more errors, see fix common Magento 2 errors.
FAQ
Can Magento 2 run on shared cPanel hosting?
Only if the plan allows enough memory, SSH and a reachable OpenSearch server. For most stores, a VPS is the more reliable choice.
Why can't I install Magento with Softaculous?
Magento 2.4 needs Composer and a search engine. One-click installers often cannot provide these on shared hosting, so the manual Composer install is more reliable.
Where is the Magento admin URL?
It is printed at the end of setup:install. You can also find it later with php bin/magento info:adminuri.
