# Como instalar Magento 2 no Ubuntu 20 da Amazon AWS

```
apt-get update 
apt-get upgrade 
```

```
systemctl stop apache2
systemctl disable apache2
```

```
apt-get install nginx
```

```
apt-get install software-properties-common
```

#### Install Elasticsearch <a href="#h-install-elasticsearch" id="h-install-elasticsearch"></a>

```
cd /opt
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-amd64.deb
dpkg -i elasticsearch-7.6.1-amd64.deb
systemctl start elasticsearch
systemctl status elasticsearch
curl -XGET 'http://localhost:9200'
```

Arrumando o erro do Elasticsearch&#x20;

```
nano /etc/elasticsearch/elasticsearch.yml

# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200

nano /etc/elasticsearch/jvm.options

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms128m
-Xmx128m
```

Instalando o PHP 7.4&#x20;

```
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php7.4
apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-bcmath php7.4-soap
apt-get install git curl software-properties-common 

nano /etc/php/7.4/fpm/php.ini
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
zlib.output_compression = On
upload_max_filesize = 128M
max_execution_time = 600
max_input_time = 900
date.timezone = America/Chicago
```

Instalando o Magento2 Gaudit

```
mkdir -p /var/www/magento2/
cd /var/www/magento2/
git clone https://github.com/gaudit/gaustore.git /var/www/magento2/
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
chown -R www-data:www-data /var/www/magento2/
```

Configurando Nginx&#x20;

```
upstream fastcgi_backend {
server unix:/run/php/php7.4-fpm.sock;
}
server {
server_name yourdomain.com;
listen 80;
set $MAGE_ROOT /var/www/magento2;
set $MAGE_MODE developer; # or production
access_log /var/log/nginx/magento2-access.log;
error_log /var/log/nginx/magento2-error.log;
include /var/www/magento2/nginx.conf.sample;
}

rm -f /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/magento2 /etc/nginx/sites-enabled/magento2

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```

```
systemctl stop apache2 
systemctl disable apache2 
```

Validar instalações das dependências

```
cd /var/www/magento2
composer install
```

```
bin/magento setup:install --base-url=http://yourdomain.com/ --db-host=localhost --db-name=magentodb --db-user=magento --db-password=strongPassword --admin-firstname=Wilker --admin-lastname=Gaudencio --admin-email=amazon@gaudit.com.br --admin-user=admin --admin-password=strong-password --language=pt_BR --currency=BRL --timezone=America/Chicago --use-rewrites=1
```
