本文档根据华为云ECS官方文档编写。
CentOS 7.6
根据实验需求配置和购买云服务
# 安装Apache
yum update -y
yum install httpd
# 配置Apache
vim /etc/httpd/conf/httpd.conf
AllowOverride None --> AllowOverride All
add: LoadModule rewrite_module modules/mod_rewrite.so
# 启动Apache
systemctl start httpd
systemctl enable httpd
# 安装MySQL
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
yum install mysql-community-server -y
# 启动MySQL
systemctl start mysqld
systemctl enable mysqld
# 初始化MySQL
grep "password" /var/log/mysqld.log
mysql_secure_installtion
# 配置数据库
mysql -u root -p
CREATE DAtABASE magento;
CREATE USER 'mangentouser'@'localhost' IDENTIFIED BY 'BLOck@123';
GRANT ALL PRIVILEGES ON mangento.* TO 'mangentouser'@'localhost';
FLUSH PRICILEGES;
exit
# 安装PHP x
yum 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 -y
# 配置PHP
vim /etc/php.ini
add: memory_limint = 256M
[Date]
add: date.timezone = Asia/Shanghai
# 重启Apache
systemctl restart httpd
# 安装Composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/bin/ --filename=composer --version=1.10.19
# 测试Composer
composer -v
# 安装Git
yum install -y git
# 克隆magento仓库
cd /var/www/html/
git clone https://github.com/magento/magento2.git
cd magento2 && git checkout tags/2.1.0 -b 2.1.0
# 迁移Magento
shopt -s dotglob nullglob && mv /var/www/html/magento2/* /var/www/html/ && cd ..
# 配置文件权限
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
# 安装unzip和zip
yum install unzip zip -y
# 安装Magento
cd /var/www/html
composer install