Comprehensive Guide to Installing Magento 2 on a cPanel Server
THE SHORT PART YOU CARE ABOUT:
In terminal window run the following.
Step one
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition
Step two
php bin/magento setup:install --base-url=http://url.com/ --db-host=localhost --db-name=yourdomain_magento2 --db-user=yourprefex_magento2 --db-password=A3nnIsEyasaM --admin-firstname=branden --admin-lastname=Thomas --admin-email=email@toweringmedia.com --admin-user=branden --admin-password=JlfsdjpSlfdgw --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=localhost --elasticsearch-port=9200 --elasticsearch-index-prefix=Yourdomain
Still stuck on installing Magento try the more in depth article below.
Need more help! Our Magento Support Department would be more then happy to help usually only take an hour or so depending on the situcation.
Magento 2 is a powerful, open-source eCommerce platform widely used by businesses to create and manage online stores. While its robust features and flexibility make it a popular choice, the complexity of the platform can sometimes present challenges. Effective Magento 2 Support is crucial for ensuring a smooth, uninterrupted shopping experience for customers. This article will provide a detailed guide to installing Magento 2 from scratch on a cPanel server.
Prerequisites
Before you begin, ensure you have the following:
- A cPanel account with access to the server.
- SSH access (if necessary).
- A domain name pointed to your server.
- Composer installed on the server (Magento 2 requires Composer).
Step 1: Prepare the Server
- Log in to cPanel:
- Access your cPanel by visiting
https://yourdomain.com:2083
and log in with your credentials.
- Access your cPanel by visiting
- Create a Database:
- Go to the Databases section and click on MySQL® Databases.
- Create a new database.
- Create a new database user and assign it to the database with all privileges.
Step 2: Set Up SSH Access (If Required)
- Enable SSH Access:
- In the Security section of cPanel, click SSH Access and manage SSH keys if required.
- Access via SSH:
- Use an SSH client (like PuTTY for Windows or Terminal for macOS/Linux) to connect to your server.
- Use your server IP and SSH port (default is 22).
Step 3: Install Composer
If Composer is not installed, follow these steps:
cd ~
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
Step 4: Download Magento
- Create a Document Root for Magento:
- In the Files section, click File Manager and navigate to your document root (
public_html
or create a new directory).
- In the Files section, click File Manager and navigate to your document root (
- Download Magento via SSH:
- Navigate to the directory where you want to install Magento:
cd /home/yourcpanelusername/public_html
- Download Magento using Composer:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .
- You will need to use your Magento Marketplace public and private keys to authenticate.
- Navigate to the directory where you want to install Magento:
Step 5: Set Up File Permissions
Set the correct permissions:
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 {} +
chown -R :yourcpanelusername .
chmod u+x bin/magento
Step 6: Install Magento
- Run the Magento Installation Wizard:
- Access the Magento installation wizard by navigating to
https://yourdomain.com
in your web browser. - Follow the on-screen instructions to complete the installation. You will need the database details you created earlier.
- Alternatively, you can install Magento via CLI:
bin/magento setup:install \ --base-url=http://yourdomain.com \ --db-host=localhost \ --db-name=yourdbname \ --db-user=yourdbuser \ --db-password=yourdbpassword \ --admin-firstname=Admin \ --admin-lastname=User \ --admin-email=admin@example.com \ --admin-user=admin \ --admin-password=admin123 \ --language=en_US \ --currency=USD \ --timezone=America/Chicago \ --use-rewrites=1
- Access the Magento installation wizard by navigating to
Step 7: Finalize Configuration
- Set Up Cron Jobs:
- Magento requires cron jobs for various tasks. Set up the following cron jobs in cPanel:
- Go to Advanced > Cron Jobs.
- Add the following cron jobs:
* * * * * /usr/local/bin/php /home/yourcpanelusername/public_html/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /home/yourcpanelusername/public_html/var/log/magento.cron.log * * * * * /usr/local/bin/php /home/yourcpanelusername/public_html/update/cron.php >> /home/yourcpanelusername/public_html/var/log/update.cron.log * * * * * /usr/local/bin/php /home/yourcpanelusername/public_html/bin/magento setup:cron:run >> /home/yourcpanelusername/public_html/var/log/setup.cron.log
- Set Up File Permissions:
- Ensure Magento has the correct permissions to function properly:
find var pub/static pub/media app/etc -type f -exec chmod g+w {} + find var pub/static pub/media app/etc -type d -exec chmod g+ws {} + chmod u+x bin/magento
- Ensure Magento has the correct permissions to function properly:
- Deploy Static Content (If Necessary):
- After making changes, you may need to deploy static content:
bin/magento setup:static-content:deploy -f
- After making changes, you may need to deploy static content:
Step 8: Secure Your Installation
- Use HTTPS:
- Ensure your website uses HTTPS by setting up an SSL certificate in cPanel under the Security section.
- Update .htaccess:
- Update the
.htaccess
file to include security best practices.
- Update the
Conclusion
By following these steps, you can successfully install Magento 2 on a cPanel server. Remember to keep your Magento installation updated and secure by regularly applying patches and updates. For additional support and services, consider reaching out to Magento 2 Support, a reliable service provider that can assist with all aspects of Magento 2 support.