Installing Magento 2 on a CentOS VPS

Magento 2 is one of the most popular e-commerce platforms. Installing Magento 2 on a CentOS VPS might seem challenging, but by following our detailed instructions, you can easily install Magento 2 on your virtual server.

Step 1: Server Preparation

Before starting the Magento 2 installation, ensure your CentOS VPS is updated and the necessary packages are installed. Execute the following commands:

  • sudo yum update
  • sudo yum install -y git
  • sudo yum install -y wget
  • sudo yum install -y unzip

Step 2: Installing and Configuring Apache and MySQL

Magento 2 requires the Apache web server and a MySQL database. Install them using the following commands:

  • sudo yum install -y httpd
  • sudo systemctl start httpd
  • sudo systemctl enable httpd
  • sudo yum install -y mariadb-server
  • sudo systemctl start mariadb
  • sudo systemctl enable mariadb

Step 3: Installing PHP and Required Extensions

Magento 2 requires PHP version 7.0 or higher and several additional modules. Install them using the following commands:

VPS Hosting

Virtual servers with guaranteed resources

Choose VPS

  • sudo yum install -y epel-release yum-utils
  • sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  • sudo yum-config-manager --enable remi-php72
  • sudo yum install -y php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

Step 4: Installing Composer and Magento 2

To install Magento 2, you need to use Composer. Install Composer with the following command:

sudo yum install -y composer

Next, clone the Magento 2 repository and install all dependencies:

git clone https://github.com/magento/magento2.git

composer install

Step 5: Web Server Configuration

Configuring Apache for Magento 2 might require adding a virtual host. Create a configuration file for your website and add the following content:

sudo vi /etc/httpd/conf.d/magento.conf

DocumentRoot /var/www/html/magento2/pub ServerName your_domain.com Options Indexes FollowSymLinks AllowOverride All Require all granted

Step 6: Completing the Installation

Restart Apache to apply the changes: sudo systemctl restart httpd

Open your browser and enter your website address. Follow the on-screen instructions to complete the Magento 2 installation.

You now have Magento 2 installed on your CentOS VPS. Enjoy working with your new online store!