背景信息:
示例步骤使用以下软件版本:
yum install httpd -y
httpd -v

vim /etc/httpd/conf/httpd.conf
在Include conf.modules.d/*.conf的下一行,添加LoadModule rewrite_module modules/mod_rewrite.so。具体步骤如下:
1.移动光标到Include conf.modules.d/*.conf下一行的行首。
2.按下i键进入编辑模式。
3.输入LoadModule rewrite_module modules/mod_rewrite.so。

AllowOverride None更改为AllowOverride All。# 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
#添加下列内容
AllowOverride All

按下ESC然后:wq保存退出。
systemctl start httpd
systemctl enable httpd
安装Mysql:
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
运行以下命令启动Mysql:
systemctl start mysqld
systemctl enable mysqld
配置Mysql:
grep 'temporary password' /var/log/mysqld.log
返回的结果是:
2022-11-06T12:24:24.653288Z 1 [Note] A temporary password is generated for root@localhost: kut0yhNKjB,q
mysql_secure_installation
安全性的配置包含以下五个方面:
1.设置root的账号密码:Ztr940407!
Enter password for user root: #输入上一步中获取的root用户密码
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: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y #是否更改root用户密码,输入Y
New password: #输入密码,长度为8至30个字符,必须同时包含大小写英文字母、数字和特殊符号。特殊符号可以是()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/
Re-enter new 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) : Y
2.输入Y删除匿名用户账号。
By 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 #是否删除匿名用户,输入Y
Success.
3.输入Y禁止root账号远程登录。
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y #禁止root远程登录,输入Y
Success.
4.输入Y删除test库以及对test库的访问权限。
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y #是否删除test库和对它的访问权限,输入Y
- Dropping test database...
Success.
5.输入Y重新加载授权表。
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y #是否重新加载授权表,输入Y
Success.
All done!

安装PHP
yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# 安装epel-release
yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php
yum -y install php70w php70w-pdo php70w-mysqlnd php70w-opcache php70w-xml php70w-gd php70w-mcrypt php70w-devel php70w-intl php70w-mbstring php70w-bcmath php70w-json php70w-iconv
php -v

配置PHP
vim /etc/php.ini
; 允许为PHP脚本分配的最大内存值。您可根据实际情况增加或减少内存限制
memory_limit = 1024M
; 设置时区为上海
date.timezone = Asia/Shanghai
ESC后输入:wq退出,并重启Apache服务。systemctl restart httpd
mysql -u root -p
magento数据库。mysql> CREATE DATABASE magento; #根据实际情况将magento替换为您需要创建的数据库名称
magento数据库创建用户。mysql> GRANT ALL ON magento.* TO <YourUser>@localhost IDENTIFIED BY '' ; #替换和为您需要创建的账号和密码
mysql> FLUSH PRIVILEGES;
例如,创建账号为magentoUser、密码为magentoUser1@3的用户,运行的命令为:(该教程直接以下面用户名和密码进行使用)
mysql> GRANT ALL ON magento.* TO magentoUser@localhost IDENTIFIED BY 'magentoUser1@3';
mysql> FLUSH PRIVILEGES;

**可选:**验证新建的Magento数据库和用户是否可用。具体步骤如下:
mysql -u <YourUser> -p #替换为您创建的账号
magento数据库。mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| magento |
+--------------------+
2 rows in set (0.00 sec)
mysql> exit

Composer是PHP的一个依赖管理工具。Composer允许您申明项目所依赖的代码库,并帮您在项目中安装依赖的代码库。
curl -sS https://getcomposer.org/installer | php
mv /root/composer.phar /usr/bin/composer
composer -v查看Composer版本。返回结果如下,表示Composer安装成功。 / ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.8.5 2019-04-09 17:46:47
composer self-update 1.8.5
您可以使用不同的方法安装Magento,可以选择是否安装示例数据。
我们使用Git下载Magento,并使用Composer安装Magento的操作步骤。
下载Magento
yum -y install git
cd /var/www/html/
git clone https://github.com/magento/magento2.git
**可选:**运行以下命令将Magento切换到稳定版本。
cd magento2 && git checkout tags/2.1.0 -b 2.1.0
命令执行后的结果如下:
Switched to a new branch '2.1.0'
说明 默认情况下,Git下载安装的Magento是最新的开发版本。如果您在生产环境中使用,建议切换到稳定版本,否则未来将无法升级安装。
shopt -s dotglob nullglob && mv /var/www/html/magento2/* /var/www/html/ && cd ..
说明 运行此命令后,您可以通过https://访问您的Magento站点。否则,您只能通过https://访问。
chown -R :apache /var/www/html
find /var/www/html -type f -print0 | xargs -r0 chmod 640
find /var/www/html -type d -print0 | xargs -r0 chmod 750
chmod -R g+w /var/www/html/{pub,var}
chmod -R g+w /var/www/html/{app/etc,vendor}
chmod 750 /var/www/html/bin/magento
composer install
打开浏览器。
在浏览器地址栏中,输入http://。
出现如下图所示页面,表示Magento安装成功。

单击Agree and Setup Magento开始配置Magento。具体步骤如下:
准备性检查。

添加数据库。
magentoUser、密码为magentoUser1@3。magento。
填写Web访问设置,并单击Next。

填写定制商店,并单击Next。
填写管理员账号信息,并单击Next。
单击Install Now进行安装。
出现如下图所示界面,表示Magento配置完成。
完成以下操作,添加cron作业:
运行crontab -u apache -e设置cron运行调度工作。
按下i键进入编辑模式。
输入下列配置信息。
*/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
按下Esc键后,输入:wq并回车以保存并退出。
Magento上使用cron作业的更多详情,请参见Magento官方文档。
输入http://登录Magento后台,如果界面提示“One or more indexers are invalid. Make sure your Magento cron job is running.”的错误信息,请参考以下步骤解决问题。
远程连接Magento服务器。具体操作,请参见连接方式概述。
运行以下命令,将PHP的安装路径建立软连接至
/usr/sbin/php
目录下。
ln -s /usr/local/php/bin/php /usr/sbin/php
运行以下命令,刷新索引。
cd /yjdata/www/wwwroot
php bin/magento indexer:reindex
回显信息类似如下所示,表示索引已刷新成功。
[root@iZbp1h2mquu8nb0jz99**** wwwroot]# php bin/magento indexer:reindex
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
刷新页面后,单击Cache Management。
选中状态为INVALIDATED的Cache Types,并单击Submit。
当出现类似如下返回信息时,表示问题已经解决。
http://可以看到如下图所示的默认主页。
刷新页面后,单击Cache Management。[外链图片转存中…(img-hL2JMwjn-1668256637476)]
选中状态为INVALIDATED的Cache Types,并单击Submit。[外链图片转存中…(img-DFhcp8LP-1668256637477)]当出现类似如下返回信息时,表示问题已经解决。[外链图片转存中…(img-YoQDOgLt-1668256637480)]
http://可以看到如下图所示的默认主页。[外链图片转存中…(img-TtKw0cUM-1668256637482)]http:///admin ,输入您在安装过程中设置的用户名和密码,成功登录管理面板后可看到如下界面。