How To Install Magento v2.3.5 Locally via the Composer

We’re excited about the recent release of Magento 2.3.5, and our team is having a blast exploring all of the goodies this release has to offer.  Over the years, we’ve discovered that it pays to get some experience with new releases prior to implementing them in our clients’ environments.  This helps us become familiar with the release and the technical nuances that come with it.

We typically install the new release in our local sandbox environment and put the release through our usual battery of tests and experiments.  If you have similar plans, we hope you’ll find this installation guide useful.  But hold your horses. . .Before you move on to the installation process, please review and validate the technology stack requirements.  We’ll start there. . .

Magento 2.3 technology stack requirements:

Server operating systems (Linux x86-64):
Linux distributions, such as RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, Debian, and similar.
Magento is not supported on Windows OS, Mac OS
Memory requirements:
Upgrading the Magento applications and extensions you obtain from Magento Marketplaces and other sources can require up to 2GB of RAM.
If you are using a system with less than 2GB of RAM, we recommend you create a swap file; otherwise, your upgrade might fail.
Composer (latest stable version):
Composer is required for developers who wish to contribute to the Magento 2 codebase or anyone who wishes to develop Magento 2 extensions.
Web servers:
Database:
  • MySQL 5.6 or 5.7
Magento is also compatible with MySQL NDB Cluster 7.4.*, MariaDB 10.0, 10.1, 10.2, Percona 5.7, and other binary-compatible MySQL technologies.
Supported PHP versions:
  • ~7.2.0
  • ~7.3.0
Required PHP extensions:
  • ext-bcmath
  • ext-ctype
  • ext-curl
  • ext-dom
  • ext-gd
  • ext-hash
  • ext-iconv
  • ext-intl
  • ext-mbstring
  • ext-openssl
  • ext-pdo_mysql
  • ext-simplexml
  • ext-soap
  • ext-xsl
  • ext-zip
  • lib-libxml
Mail server:
  • Mail Transfer Agent (MTA) or SMTP server
You can read more about system requirements from the official documentation.
In our tutorial, we will use Ubuntu (18.04) as an operating system, Nginx 1.x, Mysql 5.7, PHP-7.2, Composer, and mailcatcher as Mail sending service.
Let’s start installing LEMP (Linux, Nginx, MySQL, PHP) stack locally.
Note: If you already have all the required system environments on your local, then you can step forward to Magento 2 Installation process.

Magento 2 Environment Installation Process

Step 1 – Install Nginx
To install Nginx, run the command below.
sudo apt install nginx -y
After the installation is complete, start the Nginx service and enable it to launch every time at system boot.
systemctl start nginx
systemctl enable nginx
The Nginx installation is complete.
Step 2 – Install MySQL
Install MySQL using the command below.
sudo apt install mysql-server mysql-client -y
After the MySQL installation is complete, start the MySQL service and enable it to launch every time at system boot.
systemctl start mysql
systemctl enable mysql
And we have installed MySQL 5.7 on our local machine.
Step 2.1 – Create MySQL User (Required)
Magento requires a unique user for Magento installation, it cannot be default user: root.
First of all, you have to log in to MySQL:
sudo mysql -u root -p
Create a new database for Magento 2:
CREATE DATABASE magento2
Create a new user name call, for an example: magento2
Don’t forget to change <YOUR_PASSWORD> with your own password. But in this tutorial, we will use password as magento2
CREATE USER ‘magento2’@’localhost’ IDENTIFIED BY ‘<YOUR_PASSWORD>’;
Grant magento2 user to magento2 database:
GRANT ALL ON magento2.* TO ‘magento2’@’localhost’ IDENTIFIED BY ‘<YOUR_PASSWORD>’ WITH GRANT OPTION;
Now, it is time to flush privileges and exit.
FLUSH PRIVILEGES;
EXIT;
Step 3 – Install PHP-FPM
In this step, we will install PHP7.2-FPM with some additional extensions required by Magento 2.
Install PHP-FPM and required extensions using the command below.
sudo apt install php7.2 php7.2-common php7.2-gmp php7.2-curl php7.2-soap php7.2-bcmath php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mcrypt php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip -y
Now start the PHP-FPM service and enable it to launch every time at system boot after all installation is complete.
systemctl start php7.2-fpm
systemctl enable php7.2-fpm
Now it is time to increase values in php.ini file. Open php.ini file:
sudo nano /etc/php/7.2/fpm/php.ini
Change the following data:
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 512M
upload_max_filesize = 128M
max_execution_time = 3600
Then save this php.ini file and exit.
Step 4: Install Composer
You can use the command line to install Composer.
curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/local/bin –filename=composer
To verify the Composer installed or not just type:
composer -v
The output should be like below:

Composer version 1.10.1 2020-03-13 20:34:27

Step 5: Install Mailcatcher
During the installation, it is possible that you can get an error like install the sqllite3 library.
To do that run below command:
sudo apt install libsqlite3-dev
To start mailcatcher installation run this command.
gem install mailcatcher
To enable mailcatcher run:
mailcatcher
and go to http://localhost:1080/ address, you will see a web interface for mailcatcher.
You can set PHP’s mail configuration in your php.ini to send via MailCatcher with:
sudo nano /etc/php/7.2/fpm/php.ini
In configuration file find sendmail_path and change the following data:
sendmail_path = /usr/bin/env catchmail -f some@from.address

You should use 1025 as an SMTP port in your mail configuration setting in Magento 2 admin panel.

Magento 2 Installation process
We have installed all the required system environments. Now we can start the Magento 2 installation process.
We will install Magento 2 via the composer command. First change the directory to the /var/www/html/ folder:
cd /var/www/html/
Then run this command to install Magento 2 from composer repository:
composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition magento2
It will download the latest stable version of Magento 2 from the Magento repository.
After this to set permissions, run these commands:
sudo chown -R www-data:www-data /var/www/html/magento2/
sudo chmod -R 755 /var/www/html/magento2/
Change directory to:
cd /var/www/html/magento2/
Now we can setup Magento 2 in our local environment:
You can change –db, –admin argument values whatever you want. But be sure that you added valid MySQL (–db) credentials.

php bin/magento setup:install \

–base-url=”http://magento2.loc/” \
–db-host=”localhost” \
–db-name=”magento2″ \
–db-user=”magento2″ \
–db-password=”magento2″ \
–admin-firstname=”admin” \
–admin-lastname=”test” \
–admin-email=”admin@example.com” \
–admin-user=”admin” \
–admin-password=”admin123″ \
–language=”en_US” \
–currency=”USD” \
–timezone=”America/Chicago” \
–use-rewrites=”1″ \

–backend-frontname=”admin”

Optional: If you want to install sample data for Magento 2, you will need authentication keys from the Magento account.
Go to the official documentation page and read more detail about this process.
After getting public and private keys, you can start the sample data installation.
In your Magento 2 installed directory run this command:
php -d memory_limit=2G bin/magento sampledata:deploy

After successfully installing sample data, run the following commands one by one.

php bin/magento setup:upgrade
php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy -f

Now we need to add magento2.loc domain into the system hosts file.
sudo — sh -c “echo 127.0.0.1 magento2.loc >> /etc/hosts”
Next step is, create a new Nginx block file for our new host:
sudo nano  /etc/nginx/sites-available/magento2.conf
and paste this config data into the opened config file:

upstream fastcgi_backend {

server unix:/var/run/php/php7.2-fpm.sock;
}
server {
listen 80;
server_name magento2.loc;
set $MAGE_ROOT /var/www/html/magento2/;
set $MAGE_DEBUG_SHOW_ARGS 1;
include /var/www/html/magento2/nginx.conf.sample;
}

Now that we have our server block file, we need to enable it. We can do this by creating a symbolic link from this file to the sites-enabled directory, which Nginx reads from during startup.

sudo ln -s /etc/nginx/sites-available/magento2.conf /etc/nginx/sites-enabled/
Next, test to make sure that there are no syntax errors in any of your Nginx files:
sudo nginx -t
If no problems were found, restart Nginx to enable your changes:
sudo systemctl restart nginx
Now that you are all set up, you can test that Magento installation is functioning correctly.

You can do that by visiting the magento2.loc domain in your web browser:

http://magento2.loc

For Admin URL, use:

http://magento2.loc/admin/

And that’s a wrap!  As we dig into the release a bit deeper, we’ll share our thoughts and some additional tips and tricks.  Our goal is to help you get the most out of this release, and put the full strength of the Magento platform to work for your business.  We’d love to hear your thoughts on v2.3.5 — and if you run into any challenges, we’re here to help!  Contact Alpine today!

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *