Upgrade to Magento 2.4 on Ubuntu (18.04), including MariaDB and ElasticSearch upgrade (single machine)

Install Elasticsearch

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -sudo apt-get install apt-transport-httpsecho "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.listsudo apt-get update && sudo apt-get install elasticsearchsudo -i service elasticsearch startcurl -XGET '<host>:9200/_cat/health?v&pretty'
epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks
1519701563 03:19:23 elasticsearch green 1 1 0 0 0 0 0 0

Configure Nginx for elasticsearch

nano /etc/nginx/conf.d/magento_es_auth.conf
...
Add the following text in the editor, use 8085 or any unused port of your preference
...
server {
listen 8080;
location /_cluster/health {
proxy_pass http://localhost:9200/_cluster/health;
}
}
...
Exit your editor
...
service nginx restart
bin/magento cache:clean
bin/magento indexer:reindex

Upgrade MariaDB

mysqldump -u root -p -x -A > /home/myuser/db_backup.sql
sudo systemctl stop mariadb
sudo apt-get remove --auto-remove mariadb-server
sudo apt-get install software-properties-commonsudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main'sudo apt update
sudo apt-get install mariadb-server galera-4 mariadb-client libmariadb3 mariadb-backup mariadb-common
sudo systemctl start mariadb
DROP TABLE IF EXISTS `user`;
DROP VIEW IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS...
mysql -u root < /home/myuser/db_backup.sql
sudo mysql_upgrade --force

Upgrade magento

cp composer.json composer.json.bak
composer require magento/product-community-edition 2.4.0 --no-update
composer update
rm -rf var/cache/* var/page_cache/* var/generation/*
php bin/magento setup:upgrade
mysql -u rootGRANT ALL PRIVILEGES ON magentodb.* TO 'yourmagentodbuser'@'localhost' IDENTIFIED BY 'yourmagentodbuserpassword';FLUSH PRIVILEGES;
exit;
bin/magento setup:upgrade &&
bin/magento setup:di:compile &&
bin/magento setup:static-content:deploy -f &&
bin/magento cache:flush &&
chown -R www-data:www-data ./ &&
service php7.3-fpm restart &&
service nginx restart &&
service varnish restart

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store