Deploy a Magento e-commerce website on a Linux ECS instance with a pre-configured Alibaba Cloud Marketplace image.
Background
The Magento on LAMP CentOS7.2 64bits powered by IGS 1.0 Alibaba Cloud Marketplace image integrates Apache 2.4.23, PHP 7.0.9, MariaDB 10.1.16, Magento 2.1.0, and phpMyAdmin. See Magento on LAMP CentOS7.2 64bits powered by IGS.
You can also build a Magento2 e-commerce website on an Ubuntu instance manually.
Step 1: Build a Magento e-commerce website
Create an ECS instance with the Magento on LAMP CentOS7.2 64bits powered by IGS 1.0 Marketplace image.
-
Go to the Magento on LAMP CentOS7.2 64bits powered by IGS image details page.
-
Click Purchase Now.
-
On the Custom Launch tab in the ECS console, configure the parameters.
Note the following parameters. For other parameters, see Create an instance with Custom Launch.
-
Images: The selected Marketplace image is automatically displayed in the Images 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 database username, password, and name.
-
Connect to the Magento server.
-
Obtain the database username, password, and name:
cat /root/password.pwdSample output:
[root@iZbp1h2mquu8nb0jz99**** ~]# cat /root/password.pwd MySQL root Username: root Password: wSWTyP****
-
-
Enter
http://<Public IP address of the ECS instance>in your browser.The following page indicates that Magento is installed.

-
Click Agree and Setup Magento to start configuring Magento.
-
Click Start Readiness Check to begin the environment check.
-
After the check completes, click Next.
-
Enter the database username, password, and name, and click Next.
For the database credentials, see the Obtain the username, password, and name of the database step. Parameters:
-
Database Server Host: Enter
127.0.0.1. -
Database Server Username: Default value:
root. -
Database Server Password: The database password.
-
Database Name: Default value:
magento.
-
-
Set Your Store Address to the public IP address of the ECS instance, specify a Magento Admin Address, and click Next.
Set Your Store Address to the public IP address of the ECS instance.
NoteRecord the custom Magento Admin Address for later use.
-
Configure the store default settings and click Next:
-
Store Default Time Zone: Set to GMT (UTC)
-
Store Default Currency: Set to Chinese Yuan (CNY)
-
Store Default Language: Set to Chinese (China)
-
-
Enter the administrator account information and click Next. Required fields include:
-
New Username: Administrator username, set to
adminin this example -
New Email: Administrator email address
-
New Password: Administrator password
-
Confirm Password: Confirm the password
-
-
Click Install Now to install Magento.
After installation completes, the page displays a Success message with the following key information:
-
Magento Admin Info: Username is
admin, along with Email, Password, Store Address, and Magento Admin Address -
A yellow notice reminds you to bookmark the unique admin URL and record it offline
-
Encryption Key: Save the encryption key securely
-
Database Info: Database Name is
magento, Username isroot -
Security notice: Remove write permissions from the
/yjdata/www/wwwroot/app/etcdirectory
Click Launch Magento Admin to access the admin panel.
-
-
Step 3: Add a cron job
Magento relies on cron jobs for features such as reindexing, email generation, newsletter distribution, and sitemap creation.
-
Connect to the Magento server.
-
Configure a cron job:
crontab -e -
Press the
Ikey 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. -
Enter
http://<Public IP address of the ECS instance>in your browser. The Magento LUMA theme default homepage appears with the title Home Page and placeholder textCMS homepage content goes here., indicating that Magento is successfully installed. -
Enter
http://<Public IP address of the ECS instance>/adminin your browser. Log on with the admin credentials you configured. After successful login, the Magento 2 admin Dashboard page appears. The left navigation contains DASHBOARD, SALES, PRODUCTS, CUSTOMERS, and other menu items. The main content area shows Lifetime Sales and Average Order statistics (initial zero values are normal). The footer displays Magento ver. 2.1.1, confirming successful deployment.NoteIf the "One or more indexers are invalid. Make sure your Magento Cron job is running." error appears after you log on, see the FAQ section.
See Official Magento documentation for cron job usage.
(Optional) Step 4: Bind a domain name and configure resolution settings for the domain name
Bind a domain name to your ECS instance so users can access the website by domain name.
-
Register a domain name.
See Register a domain name on Alibaba Cloud. Skip this step if you already have a domain name.
Sample domain name:
example.com. -
If the website is hosted on an ECS instance in a region inside the Chinese mainland, apply for an 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. The system automatically resolves the domain name after binding.
-
If your domain name is not registered with Alibaba Cloud or resolved by Alibaba Cloud DNS, add it in the Alibaba Cloud DNS console. See Manage domain names. You can also contact your domain name service provider, create an A record pointing to the Magento server IP address, and bind the domain name.
-
FAQ
If the "One or more indexers are invalid. Make sure your Magento cron job is running." error appears when you access http://<Public IP address of the ECS instance>/admin, follow these steps. The Magento admin panel displays a warning in the System messages panel: One or more indexers are invalid. Make sure your Magento cron job is running.
-
Connect to the Magento server.
-
Create a symbolic link from the PHP installation path to
/usr/sbin/php:ln -s /usr/local/php/bin/php /usr/sbin/php -
Perform reindexing:
cd /data/wwwroot/default php bin/magento indexer:reindexOutput similar to the following 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. A cache invalidation warning appears at the top of the page indicating that the Page Cache is invalidated. Click the Cache Management link in the warning to go to the cache management page.
-
On the Cache Management page, select the Page Cache with status INVALIDATED, choose Refresh from the action dropdown, and click Submit to refresh the cache.
The page displays a success message
1 cache type(s) refreshed., indicating the cache was refreshed successfully.