Overview
Magento is a leading open-source eCommerce platform offeringpowerful features for creating and managing online stores. This article willguide you through installing Magento on your Virtual Private Server (VPS) withHSJ.HOST, allowing you to take advantage of its extensive functionality tobuild a robust online store.
Prerequisites
- A VPS account with HSJ.HOST.
- SSH access to your server.
- A LAMP (Linux, Apache, MySQL, PHP) or LEMP (Linux, Nginx, MySQL, PHP) stack installed on your VPS.
- Composer installed on your VPS for Magento 2 installations.
- Basic knowledge of the Linux command line.
Procedure
1. Access Your VPS via SSH
- Use your terminal to SSH into your VPS: ssh user@your_vps_ip, substituting user with your actual username and your_vps_ip with the IP address of your VPS.
2. Update Your Server's Packages
- Refresh your package list with sudo apt update.
- Upgrade your packages to their latest versions using sudo apt upgrade.
3. Create a MySQL Database for Magento
- Log into MySQL as the root user: sudo mysql -u root -p.
- Create a new database for Magento:
Sql code
CREATE DATABASE magento_db;
- Create a new MySQL user and grant them full access to the new database:
sql code
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY'a_secure_password'; GRANT ALL PRIVILEGES ON magento_db.* TO'magento_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
4. Install Magento
- Navigate to the web root directory (e.g., /var/www/html) and download Magento using Composer. Replace your_project_name with your desired project directory name:
bash code
composer create-project--repository-url=https://repo.magento.com/ magento/project-community-editionyour_project_name
- Follow the on-screen instructions to complete the Composer installation. You may need to enter your Magento Marketplace credentials.
5. Set Permissions
- Change the directory to your Magento project: cd your_project_name.
- Set the appropriate permissions for your Magento directories and files:
bash code
find var generated vendor pub/static pub/media app/etc -typef -exec chmod g+w {} \; find var generated vendor pub/static pub/media app/etc-type d -exec chmod g+ws {} \; chown -R :www-data . chmod u+x
bin/magento
6. Run Magento Setup
- Initiate the Magento setup script via the command line, replacing placeholders with your information:
Arduino code
bin/magento setup:install \--base-url=http://your_domain.com \ --db-host=localhost \ --db-name=magento_db\ --db-user=magento_user \ --db-password=a_secure_password \--admin-firstname=Admin \ --admin-lastname=User \--admin-email=user@example.com \ --admin-user=admin \--admin-password=a_strong_admin_password \ --language=en_AU \ --currency=AUD \--timezone=Australia/Sydney \ --use-rewrites=1
- Adjust the --base-url, --admin-firstname, --admin-lastname, --admin-email, --admin-user, and --admin-password as necessary.
7. Configure Your Web Server
- For Apache, ensure you have a .htaccess file in your Magento installation root. Magento provides this by default.
- For Nginx, configure your site available file to correctly handle Magento's front controller: refer to Magento's documentation for example configurations.
Conclusion
You have successfully installed Magento on your VPS, layingthe foundation for a powerful eCommerce platform. Begin by exploring Magento'sadmin panel, setting up your catalog, and customising your store's appearancewith themes and extensions to match your business needs.