Ubuntu 20.04上安装Nginx,MySQL,PHP
`sudo apt update`
安装Nginx
`sudo apt install nginx`
安装PHP7.4
```
sudo apt install php7.4 php7.4-common php7.4-cli
sudo apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-readline php7.4-zip php7.4-mysql php7.4-soap php7.4-xml php7.4-mbstring
```
安装mysql
```
sudo apt-get install mysql-server mysql-client
alter user 'root'@'localhost' identified with mysql_native_password by '123456';//mysql8 needs to run
```
安装Composer
```
wget https://github.com/composer/composer/releases/download/1.10.22/composer.phar
mv composer.phar composer
chmod +x composer
sudo mv composer /usr/local/bin
```
安装ES(mount /dev/sdb /tmp)
`wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.0-linux-x86_64.tar.gz
`
下载Magento2.4.0
```
php -d memory_limit=-1 /usr/local/bin/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.0 /var/www/html/magento
```
安装Magento2.4.0
```
bin/magento setup:install --base-url=http://magento2-4.com/ \
--db-host=localhost --db-name=magento2_4_0 --db-user=root --db-password=123456 \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1 \
--search-engine=elasticsearch7 --elasticsearch-host=localhost \
--elasticsearch-port=9200
```
关闭2FA
```
bin/magento module:disable Magento_TwoFactorAuth
```
安装示例数据
```
bin/magento sampledata:deploy
bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData
rm -rf var/cache/* var/page_cache/* var/generation/*
bin/magento setup:upgrade
bin/magento setup:di:compile
```