dev-resources.site
for different kinds of informations.
Magento 2 ARM Ubuntu Server 24.04 AMD installation sh script
Two years ago, I was the first person who researched Magento performance and installation on ARM Graviton(AWS) and Amper(Oracle) servers. However, since then, AWS and Linux have improved support ARM graviton architecture and support. Previously, there was an issue with the same software support from the Linux repos, and you need to install it from the sources. Now, you can install everything from the default Ubuntu repo.
I wrote a new performance and installation script for the Graviton 4 C8g AWS instance.
The new AWS Ubuntu image has better support for ARM compiler software from the default repository.
So here is the Magento C8g Ubuntu Server 24 instance installation script:
https://github.com/Genaker/Magento-Linux-Installation/blob/master/magento2-ubuntu24-arm-installation.sh
Magento 2 Installation Steps:
- Nginx Config
- Setup NGINX
- Setup PHP
- Configure PHP
- Configure Opcache
- Setup MySQL 8
- Setup OpenSearch/ElasticSearch
- Setup Redis
- Setup Composer
- Setup Magento from the composer
- Set Nginx Config
- Set Folder Permissions
Just run this script as user data or manually, and you will have the magento ubuntu 24 server up and running.
`
MAGE_URL="ec2-98-81-130-207.compute-1.amazonaws.com"
PHP_VERSION="8.1"
OPENSEARCH_VERSION="2.11.1"
magento2conf="upstream fastcgi_backend {
server unix:/run/php/php$PHP_VERSION-fpm.sock;
}
server {
listen 80;
server_name $MAGE_URL;
set \$MAGE_ROOT /var/www/html/magento;
include /var/www/html/magento/nginx.conf.sample;
}"
sudo apt-get update
Setup NGINX
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo apt install unzip -y
Setup PHP
sudo apt install -y software-properties-common
yes | sudo add-apt-repository ppa:ondrej/php
sudo apt-get install php$PHP_VERSION php$PHP_VERSION-dev php$PHP_VERSION-fpm php$PHP_VERSION-bcmath php$PHP_VERSION-intl php$PHP_VERSION-soap php$PHP_VERSION-zip php$PHP_VERSION-curl php$PHP_VERSION-mbstring php$PHP_VERSION-mysql php$PHP_VERSION-gd php$PHP_VERSION-xml --no-install-recommends -y
php -v
Configure PHP
sudo sed -i 's/^(max_execution_time = )[0-9]/\17200/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/^(max_input_time = )[0-9]/\17200/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/^(memory_limit = )[0-9]*M/\12048M/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/^(post_max_size = )[0-9]*M/\164M/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/^(upload_max_filesize = )[0-9]*M/\164M/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/expose_php = On/expose_php = Off/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/;realpath_cache_size = 16k/realpath_cache_size = 512k/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/;realpath_cache_ttl = 120/realpath_cache_ttl = 86400/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/short_open_tag = Off/short_open_tag = On/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/;max_input_vars = 1000/max_input_vars = 50000/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 28800/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/mysql.allow_persistent = On/mysql.allow_persistent = Off/' /etc/php/$PHP_VERSION/fpm/php.ini
sudo sed -i 's/mysqli.allow_persistent = On/mysqli.allow_persistent = Off/' /etc/php/$PHP_VERSION/fpm/php.ini
Configure Opcache
sudo bash -c "cat > /etc/php/$PHP_VERSION/fpm/conf.d/10-opcache.ini <<END
zend_extension=opcache.so
opcache.enable = 1
opcache.enable_cli = 0
opcache.memory_consumption = 356
opcache.interned_strings_buffer = 4
opcache.max_accelerated_files = 100000
opcache.max_wasted_percentage = 15
opcache.use_cwd = 1
opcache.validate_timestamps = 0
;opcache.revalidate_freq = 2
;opcache.validate_permission= 1
;opcache.validate_root= 1
opcache.file_update_protection = 2
opcache.revalidate_path = 0
opcache.save_comments = 1
opcache.load_comments = 1
opcache.fast_shutdown = 1
opcache.enable_file_override = 0
opcache.optimization_level = 0xffffffff
opcache.inherited_hack = 1
opcache.max_file_size = 0
opcache.consistency_checks = 0
opcache.force_restart_timeout = 60
opcache.log_verbosity_level = 1
opcache.protect_memory = 0
END"
sudo systemctl start php$PHP_VERSION-fpm.service
sudo systemctl enable php$PHP_VERSION-fpm.service
sudo systemctl status php$PHP_VERSION-fpm.service --no-pager
sudo systemctl restart php$PHP_VERSION-fpm.service
Setup MySQL
sudo apt install mysql-server -y
sudo systemctl start mysql
sudo systemctl enable mysql
sudo mysql -e "CREATE DATABASE magento; CREATE USER 'magento'@'localhost' IDENTIFIED BY 'magento'; GRANT ALL ON magento.* TO 'magento'@'localhost'; FLUSH PRIVILEGES;"
sudo mysql -e "show databases"
sudo mysql -e "SET GLOBAL log_bin_trust_function_creators = 1;"
sudo mysql -e "select version()"
Setup OpenSearch
curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring
echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-2.x.list
sudo apt update
sudo apt list -a opensearch
sudo apt install opensearch=$OPENSEARCH_VERSION
apt purge opensearch -y
sudo bash -c "echo \"plugins.security.disabled: true\" >> /etc/opensearch/opensearch.yml"
sudo cat /etc/opensearch/opensearch.yml
sudo systemctl enable --now opensearch
sudo systemctl restart opensearch
sudo systemctl status opensearch
logs : cat /etc/opensearch/opensearch.yml
curl -X GET localhost:9200
Setup Redis
sudo apt install redis -y
sudo systemctl restart redis.service
sudo systemctl status redis
Setup Composer
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
composer -V
sudo mkdir /var/www/html/magento
sudo chmod -R 755 /var/www/html/magento/
composer config --global http-basic.repo.magento.com 5310458a34d580de1700dfe826ff19a1 255059b03eb9d30604d5ef52fca7465d
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition /var/www/html/magento
cd /var/www/html/magento/
bin/magento setup:install --base-url=http://$MAGE_URL --db-host=localhost --db-name=magento --db-user=magento --db-password=magento --admin-firstname=Magento --admin-lastname=Admin --admin-email=[email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --search-engine=opensearch
yes | /var/www/html/magento/bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-db=0
yes | /var/www/html/magento/bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=127.0.0.1 --page-cache-redis-db=1
yes | /var/www/html/magento/bin/magento setup:config:set --session-save=redis --session-save-redis-host=127.0.0.1 --session-save-redis-log-level=4 --session-save-redis-db=2
php bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth
php bin/magento module:disable Magento_TwoFactorAuth
sudo bash -c "echo '$magento2conf' > /etc/nginx/conf.d/magento.conf"
sudo nginx -t
sudo service nginx restart
sudo chmod -R 777 /var/www/html/magento/*
curl http://$MAGE_URL
tail -n 20 /var/log/nginx/error.log
sudo chown -R www-data:www-data /var/www/html/magento
sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
`
Magento 2 ARM Performance
AWS C5.large has 0.032 PHP performance score (less is better). Cli Performace 0.110ms
AWS C8.xlarge has 0.029 PHP performance score (less is better), CLI performace is: 0.066 for Cli opcache doesn't work. It is well known PHP issue.
So, Graviton 4 instances have ~20% greater PHP performance score, especially for corn operations.
More about Magento 2 PHP performance test here:
https://github.com/Genaker/Magento2OPcacheGUI
C8g instances offer up to 30% better performance and larger instance sizes with up to 3x more vCPUs and memory than the seventh-generation AWS Graviton3-based C7g instances.
The cost of the ARM Graviton 4 C8g.48xlarge with 192 physical (it is twice more than Intel with 192 virtual CPUs. You can count it as 384 CPUs) CPUs is $ 5,000 per month. It can handle any load as a web server. It will handle approximately 200 uncached requests per second without any issues. But you can scale it down and reduce the cost. For example, if you need only 20 uncached requests per second, you can pay 500$ per month for the C8g.4xlarge (16CPUs) computed resources and you can also apply AWS cost savings.
Featured ones: