Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of building Magento e-commerce website on Linux instance

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to build a Magento e-commerce site on an Linux instance. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

Build Magento e-commerce website on Linux instance

Magento is an open source e-commerce website framework, its rich modular architecture and extended functions can provide solutions for large and medium-sized sites. It is developed using PHP, supports versions ranging from PHP 5.6 to PHP 7.1, and uses MySQL to store data. This paper mainly explains how to build Magento e-commerce website on Aliyun ECS instance, using Linux CentOS 7.264-bit operating system.

Applicable object

It is suitable for users who are familiar with ECS and Linux system and are just beginning to use Aliyun to build a station.

Resources

The Linux ECS instance configurations described in this article include: 2 vCPU, 4 GiB memory, Cent OS 7.264-bit operating system, VPC network, and assigned public network IP address.

Description: for building a Magento 2 server, the memory cannot be less than 2 GiB.

According to the Magento e-commerce website built in this paper, the software version information used is as follows:

MySQL 5.7

PHP 7.0

Magento 2.1

prerequisite

You have created a Linux ECS instance of VPC network type. For more information, see creating an ECS instance. Configuration includes: 2 vCPU, 4 GiB memory, Cent OS 7.264-bit operating system, VPC network, allocation of public network IP address.

The security group rules shown in the following table have been added to the security group where the ECS instance resides. For more information, see creating ECS instances and adding Security Group rules.

Operation steps

The steps for building a Magento website using CVM ECS are as follows:

Step 1. Install and configure the LAMP platform

Step 2. Create a database

Step 3. Install and configure Composer

Step 4. Install and configure Magento

Step 5. Add cron Job

Step 1. Install and configure the LAMP platform

This section explains how to install the LAMP platform manually. You can also purchase a LAMP image in the cloud market to launch the ECS instance directly, so that you can quickly build a site.

Run the following command to update the package and repository, and install the Apache Web server and MySQL server.

# yum-y update# yum-y install httpd# rpm-Uvh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm# yum-y install mysql-community-server

Start HTTP and MySQL services and set up boot self-startup.

# systemctl start httpd# systemctl enable httpd# systemctl start mysqld# systemctl enable mysqld

Edit the Apache configuration file:

Run the command vim / etc/httpd/conf/httpd.conf.

Press I to enter edit mode.

Make the following changes:

Add LoadModule rewrite_module modules/mod_rewrite.so after Include conf.modules.d/*.conf.

Change the AllowOverride None of the following to AllowOverride all.

Options Indexes FollowSymLinks

# AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:# Options FileInfo AuthConfig Limit#AllowOverride None

Press Esc to exit editing and enter: wq to save and exit.

Check the / var/log/mysqld.log file to get the root user password that is automatically set when you install MySQL.

# grep 'temporary password' / var/log/mysqld.log2016-12-13T14:57:47.535748Z 1 [Note] A temporary password is generated for root@localhost: p0/G28g > lsHD

Running the following command can improve the security of MySQL in the following four aspects:

Set the password for root account

Remote login of root account is prohibited

Delete anonymous user account

Delete test library and access to test library

Details can be found in the official documentation.

# mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root: # enter the root user password obtained in step 4: The 'validate_password' plugin is installed on the server.The subsequent steps will run with the existing configuration of the plugin.Using existing password for root.Estimated strength of the password: 100Change the password for root? ((Press y | Y for Yes, any other key for No): y # whether to change the root user password, enter YNew password: # enter password Re-enter new password: # enter password Estimated strength of the password: 100 Do you wish to continue with the password provided? (Press y | Y for Yes, any other key for No): YBy default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.Remove anonymous users? (Press y | Y for Yes, any other key for No): y # whether to delete anonymous users, enter YSuccess.Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.Disallow root login remotely? (Press y | Y for Yes, any other key for No): y # forbids root remote login, enter YSuccess.By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y | Y for Yes, any other key for No): y # do you want to delete the test library and access to it, enter Y-Dropping test database...Success.- Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y | Y for Yes, any other key for No): whether or not Y # reloads the authorization table, enter YSuccess.All done!

Run the following command in turn to install PHP 7 and some additional PHP extensions you need.

# yum install-y http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-14.ius.centos7.noarch.rpm# yum-y update# yum-y install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-gd php70u-mcrypt php70u-devel php70u-intl php70u-mbstring php70u-bcmath php70u-json php70u-iconv

Check the PHP version to verify that PHP has been successfully installed.

# php-vPHP 7.0.13 (cli) (built: Nov 10 2016 08:44:18) (NTS) Copyright (c) 1997-2016 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.13, Copyright (c) 1999-2016, by Zend Technologies

Edit the configuration file / etc/php.ini:

Run the command vim / etc/php.ini.

Press I to enter edit mode.

Add the following configuration at the end of the file:

Memory_limit = 128m # increase the memory limit according to the actual situation

Date.timezone = Asia/Shanghai # sets the time zone to Shanghai.

Restart the Web service process.

# systemctl restart httpd

Step 2. Create a database

Follow these steps to create the database.

Create database and users: create a database and a database user for Magento data. The database and user name can be modified according to the actual situation.

# mysql-u root-pEnter password: mysql > CREATE DATABASE magento; # replace magentoQuery OK according to instance, 1 row affected (0.00 sec) mysql > GRANT ALL ON magento.* TO YourUser@localhost IDENTIFIED BY 'YourPass'; # replace YourUser and YourPassQuery OK according to actual situation, 0 rows affected, 1 warning (0.00 sec) mysql > FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)

Run exit to exit MySQL.

(optional) verify that the newly created Magento database and users are available.

# mysql-u YourUser-pmysql > show databases;+-+ | Database | +-+ | information_schema | | magento | +-+ 2 rows in set (0.00 sec) mysql > exit

Step 3. Install and configure Composer

Composer is a package management and package dependency management tool for PHP. Follow these steps to install and configure Composer.

Install Composer.

# curl-sS https://getcomposer.org/installer | phpAll settings correct for using ComposerDownloading 1.2.4...Composer successfully installed to: / root/composer.pharUse it: php composer.phar

Configure Composer global use.

# mv / root/composer.phar / usr/bin/composer

Test whether the command is available.

# composer-vault / _ / _ / / / _ / / _ _ / / _ _ / / / / (_ _) _ / / /\ _ / /\ _ / /. _ _ / /\ _ _ / _ / / Composer version 1.2.4 2016-12-06 22:00:51

Step 4. Install and configure Magento

You can install Magento using different methods, or you can choose whether or not to install sample data. If you install Magento for testing purposes only, you can choose to install the sample data. If you are installing Magento in a production environment, it is recommended that you install a brand new Magento and configure it from scratch.

This section describes how to download Magento using git, and then install Magento using Composer.

Run the following command in turn to download Magento through git clone.

# yum-y install git# cd / var/www/html/# git clone https://github.com/magento/magento2.git

(optional) switch Magento to a stable version.

By default, git download and install Magento is the latest development version. If you use it in a production environment, it is recommended to switch to a stable version, otherwise you will not be able to upgrade the installation in the future.

# cd magento2 & & git checkout tags/2.1.0-b 2.1.0Switched to a new branch '2.1.0'

Move the installation file to the root of the Web server. Otherwise, you can only access your Magento site through the public network IP address of http://[ECS instance] / magento2.

# shopt-s dotglob nullglob & & mv / var/www/html/magento2/* / var/www/html/ & & cd.

Set the appropriate permissions for the Magento file.

# chown-R: apache / var/www/html# find / var/www/html-type f-print0 | xargs-R0 chmod 64 percent find / var/www/html-type d-print0 | xargs-R0 chmod 75 percent chmod-R Grouw / var/www/html/ {pub,var} # chmod-R Grouw / var/www/html/ {app/etc,vendor} # chmod 750 / var/www/html/bin/magento

Run composer install to install Magento.

Test: access the public network IP address of the http://[ECS instance in the browser. If the following page appears, the Magento is installed successfully.

Click Agree and Setup Magento to start configuring Magento: fill in the connection database information, Web access settings, customize the store, and create an administrator account according to the actual situation. When the interface shown in the following figure appears, the Magento configuration is complete

Step 5. Add cron Job

Run crontab-u apache-e to set up cron to run the scheduling work.

Add the following.

* / 10 * php-c / etc / var/www/html/bin/magento cron:run*/10 * php-c / etc / var/www/html/update/cron.php*/10 * php-c / etc / var/www/html/bin/magento setup:cron:run Thank you for reading! So much for the method of building Magento e-commerce website on Linux examples. I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report