Magento is an open source e-commerce platform written in PHP. It provides a modular architecture and varied expansion features for building large and medium-sized websites and uses MySQL to store data. This topic describes how to use an Alibaba Cloud Marketplace image to build a Magento e-commerce website.
Background information
The Magento on LAMP CentOS7.2 64bits powered by IGS 1.0
Alibaba Cloud Marketplace image is integrated with Apache 2.4.23, PHP 7.0.9, MariaDB 10.1.16, Magento 2.1.0, and phpMyAdmin. For more information, see Magento on LAMP CentOS7.2 64bits powered by IGS.
In addition to using an Alibaba Cloud Marketplace image, you can also manually build a Magento e-commerce website. For more information, see Manually build a Magento e-commerce website on an ECS instance.
Step 1: Build a Magento e-commerce website
In this example, an Elastic Compute Service (ECS) instance that runs a Magento on LAMP CentOS7.2 64bits powered by IGS 1.0 Alibaba Cloud Marketplace image is created to build a Magento e-commerce website.
Click Magento on LAMP CentOS7.2 64bits powered by IGS to go to the image details page.
Click Choose Your Plan.
On the Custom Launch tab in the ECS console, configure the parameters.
Take note of the following parameters. For information about other parameters, see Create an instance on the Custom Launch tab.
Image: The Magento on LAMP CentOS7.2 64bits powered by IGS 1.0 image that you specified is automatically displayed in the Image section.
Public IP Address: Select Assign Public IPv4 Address.
Security Group: Specify a security group that allows traffic on ports 22, 80, 443, and 3306.
Step 2: Configure a Magento client
Obtain the username, password, and name of the database.
Connect to the Magento server.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to obtain the username, password, and name of the database:
cat /root/password.pwd
A command output similar to the following one is returned:
[root@iZbp1h2mquu8nb0jz99**** ~]# cat /root/password.pwd MySQL root Username: root Password: wSWTyP****
In the address bar of your browser, enter
http://<Public IP address of the ECS instance>
.The following page indicates that Magento is installed.
Click Agree and Setup Magento to start configuring Magento.
Click Start Readiness Check to start the readiness check.
After the check is complete, click Next.
Enter the username, password, and name of the database, and then click Next.
For information about how to obtain the username, password, and name of the database, see the Obtain the username, password, and name of the database step in this section. The following list describes the parameters:
Database Server Host: the host IP address of the database. Enter
127.0.0.1
.Database Server Username: the username of the database. Default value:
root
.Database Server Password: the password of the database.
Database Name: the name of the database. Default value:
magento
.
Enter the website access address in the Your Store Address field, specify a backend management address in the Magento Admin Address field, and then click Next.
Set Your Store Address to the public IP address of the ECS instance.
NoteYou can specify a custom backend management address (Magento Admin Address). Remember the address that you specified.
Configure parameters such as Store Default Time Zone and Store Default Language, and click Next.
Configure an admin account and set a password, and then click Next.
Click Install Now to install Magento.
The following page indicates that Magento is configured.
Step 3: Add a cron job
Cron jobs are required for a large number of features of Magento e-commerce websites, such as reindexing, email generation, newsletter distribution, and sitemap creation. You can configure and run cron jobs to perform scheduled tasks.
Connect to the Magento server.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to configure a cron job:
crontab -e
Press the
I
key to enter Insert mode and add the following content to the file:*/10 * * * * php -c /etc /data/wwwroot/default/bin/magento cron:run */10 * * * * php -c /etc /data/wwwroot/default/update/cron.php */10 * * * * php -c /etc /data/wwwroot/default/bin/magento setup:cron:run
Press the Esc key, enter
:wq
, and then press the Enter key to save and close the file.In the address bar of your browser, enter
http://<Public IP address of the ECS instance>
. The default homepage is displayed, as shown in the following figure.In the address bar of your browser, enter
http://<Public IP address of the ECS instance>/admin
, and enter the account username and password of the Magento website that you configured. After you log on to the management console, the following page appears.NoteIf the "One or more indexers are invalid. Make sure your Magento Cron job is running." error message appears after you log on to the Magento website, see the FAQ section in this topic.
For more information about how to use cron jobs in Magento, see Official Magento documentation.
(Optional) Step 4: Bind a domain name and configure resolution settings for the domain name
To facilitate access to and use of the website, you can configure a unique domain name for the website and use the domain name to access the website.
Register a domain name.
For more information, see Register a domain name on Alibaba Cloud. If you have registered a domain name, skip this step.
Sample domain name:
example.com
.If the website to which the domain name points is hosted on a simple application server in a region inside the Chinese mainland, you must apply for an Internet Content Provider (ICP) filing for the domain name.
(Optional) Map the domain name to the public IP address of the ECS instance.
If your domain name is registered with Alibaba Cloud, skip this step. After the domain name is bound to the Magento server, the system automatically resolves the domain name.
If your domain name is not registered with Alibaba Cloud or resolved by Alibaba Cloud DNS, you can add the domain name in the Alibaba Cloud DNS console to resolve the domain name. For more information, see Manage domain names. You can also contact the service provider of the domain name, create an A record for the domain name that points to the IP address of the Magento server, and then bind the domain name.
FAQ
If the "One or more indexers are invalid. Make sure your Magento cron job is running." error message appears when you enter http://<Public IP address of the ECS instance>/admin
in your browser to connect to the Magento website, perform the following steps to resolve the issue:
Connect to the Magento server.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to create a symbolic link from the PHP installation path to the
/usr/sbin/php
directory:ln -s /usr/local/php/bin/php /usr/sbin/php
Run the following commands to perform reindexing:
cd /data/wwwroot/default php bin/magento indexer:reindex
A command output similar to the following one indicates that reindexing is complete.
Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:00 Category Products index has been rebuilt successfully in 00:00:00 Product Categories index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:00:00 Product EAV index has been rebuilt successfully in 00:00:00 Stock index has been rebuilt successfully in 00:00:00 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00 Catalog Search index has been rebuilt successfully in 00:00:00
Refresh the page and click Cache Management.
Select the caches for which INVALIDATED is displayed in the Status column and click Submit. In this example, Page Cache is selected. A command output similar to the following one indicates that the issue is resolved.