This document covers the installation process of Magento 2.4.2 on an EC2 instance of Ubuntu 20.04
Before beginning the installation process, you must create an account at https://magento.com/
After creating an account, acquire your public and private keys, needed for a later step, by visiting this site. Once on there, click on your name in the top right corner and then click on "My Profile". Once there, click on "Access Keys", located under Marketplace > My Products.
Assuming you don't already have an access key created, simply create one and name it something appropriate. Once created, make note that in a later step, your public key will act as your username and your private key will act as your password.
sudo adduser magento
sudo usermod -aG sudo magento
- Adds user to the
sudo -iu magento
- Logs in as
sudo apt -y install nginx
apt-get -y install php7.4-fpm
- Might possibly need to run
apt-get -y install php7.4-cli
- Open the
php.inifiles in an editor:
- Edit both to include the following values:
memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On
- Save the changes you made and restart PHP with
systemctl restart php7.4-fpm
sudo apt install mariadb-server
This will launch the configurator for mariaDB
Enter current password for root (enter for none): Press [Enter] since no password is set by default Set root password? [Y/n]: Y (Keep this password handy for a later step) Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
systemctl status mariadb.service
systemctl enable mariadb.service
sudo mysql -u root -p
- Enter the
magentouser password when asked
- Enter the following commands in the order shown to create a database instance named magento with username magento:
create database magento; create user 'magento'@'localhost' IDENTIFIED BY 'Password'; GRANT ALL ON magento.* TO 'magento'@'localhost'; flush privileges;
mysql -u magento -p
- Use the root password we set up in the second SQL statement referenced as
use magento;and ensure the output is
Starting with version 2.4, Magento requires that Elasticsearch be utilized
sudo dpkg -i elasticsearch-7.6.1-amd64.deb
sudo systemctl start elasticsearch
sudo systemctl status elasticsearch
curl -XGET 'http://localhost:9200'
sudo vim /etc/elasticsearch/elasticsearch.yml
cluster.name: Magento Cluster
node.name: Magento Node
systemctl restart elasticsearch.service
curl -XGET 'http://localhost:9200'to confirm changes are reflected
sudo usermod -g www-data magento
sudo chown -R magento:www-data /var/www/html/
Installing PHP Extensions
At this point, I found that before I could run the
composer command in the next section, I had several php extensions I had to install. Those were:
- Installing Magento
sudo apt install zip unzip php-zip
cd /var/www/htmland ensure the directory is empty of any contents. Generally, Nginx have a test file in here that you will need to delete.
- Install composer globally:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer
composer create-project --repository=<https://repo.magento.com/ magento/project-community-edition .
- When prompted, provide public key as username and private key as password
Once finished, you may be presented with some messages highlighted in yellow. These are not necessarily anything to worry about unless they're explicitly warnings or if the highlighting is red instead of yellow.
We now run the composer install command to actually install Magento, itself
composer install bin/magento setup:install \ --base-url=<http://localhost/magento2ee> \ --db-host=localhost \ --db-name=magento \ --db-user=magento \ --db-password=db_password \ --backend-frontname=admin \ --admin-firstname=Tanner \ --admin-lastname=Cude \ --admin-email=email \ --admin-user=magentoadmin \ --admin-password=alphanumberic_password \ --language=en_US \ --currency=USD \ --timezone=America/Chicago \ --use-rewrites=1
Note that this step may take several minutes to install.
Stay tuned for an additional post describing how to configure Nginx to work with Magento – allowing users to access your Magento site.