Home Apache Install Magento 2 On Ubuntu 16.04 | 18.04 With Apache2, Percona DB...

Install Magento 2 On Ubuntu 16.04 | 18.04 With Apache2, Percona DB and PHP 7.2

3

Here we are going to discuss how to install Magento 2 latest version easily. This post helps you to setup Magento 2 with Composer.

This will help new users to Install Magento 2 On Ubuntu 16.04 | 18.04 With Apache2, Percona DB and PHP 7.2

When you use Composer to install Magento 2 packages, you can easily upgrade from the commmand line with Composer.

This tutorial is going to show new users how to install / upgrade Magento 2 (CE 2.3.3) from Github repository via Composer with Apache2, Percona DB and PHP 7.2 on Ubuntu 16.04 | 18.04 LTS servers…

To get started with installing Magento 2.3.3, follow the steps below:

Step 1: Install Apache 2.4.x (HTTP)Web Server on Ubuntu 16.04-18.04 LTS

The Apache HTTP Server, colloquially called Apache, is free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation

Please follow below steps to install Apache HTTP server

$ sudo apt update
$ sudo apt install apache2
$ apache2 -v (to check apache version)

Use below commands to enable Apache2 with startup and start, restart & stop Apache2 service.

sudo systemctl enable apache2.service
sudo systemctl start apache2.service
sudo systemctl restart apache2.service
sudo systemctl stop apache2.service

Once you finish the installation, you need to enable the Apache mod_rewrite module using below commands

$ sudo a2enmod rewrite
$ sudo service apache2 restart

To test the Apache setup, open your browser and type your server IP address or host name. If you can see below Apache landing page you have installed HTTP server correctly.

Apache2 landing page

Refer Apache Virtual hosts configuration at;

Step 2: Install Percona Server 5.7 on Ubuntu 16.04-18.04 LTS

Percona Server for MySQL is a distribution of the MySQL relational database management system created by Percona. Percona Server for MySQL is an open source relational database management system. It is a free, fully compatible drop in replacement for Oracle MySQL

To Install Percona Server please follow below steps;

$ wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb

$ sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb

$ sudo apt-get update

$ sudo apt-get install percona-server-server-5.7

During the installation, setup will prompt for “root” password and keep it safe place to work with the server in the future. Please use below command to access Percona Server.

$ mysql -u root -p "your password"

After installing Percona server, the commands below can be used to stop, start and enable Percona server service to always start up when the server boots..

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

PHP: Hypertext Preprocessor is a general-purpose programming language originally designed for web development. It was originally created by Rasmus Lerdorf in 1994; the PHP reference implementation is now produced by The PHP Group

Please follow below steps to install PHP 7.2 with required modules to run Magento 2.3.3 installation.

PHP 7.1 may not be available in Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php

Please run below command to update repository

$ sudo apt update

Please run below command to install PHP and relate modules

$ sudo apt install php7.2 libapache2-mod-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-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip

After installation you can use below commands to check PHP version and modules installed.

$ php -v
$ php -m
PHP 7.2.24-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 24 2019 18:29:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

After installing PHP 7.1, run the commands below to open PHP default config file for Apache2
You need to change below parameters to work with Magento 2

$ sudo nano /etc/php/7.2/apache2/php.ini

Then make the changes on the following lines below in the file and save. The value below is great settings to apply in your environments.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 768M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

After making the above change, save the file and close out and restart the Apache service to effect changes

$ sudo systemctl restart apache2.service

To test PHP 7.2 settings with Apache2, create a phpinfo.php file in the Apache2 root directory by running the commands below.

$ sudo nano /var/www/html/phpinfo.php

Paste below code and save the file

<?php phpinfo( ); ?>

Try to access http://localhost/phpinfo.php You should see PHP settings page as below

PHP info page

Step 4: Create Magento Database

Our server is ready with all the prerequisites to install Magento 2, but we need to create Magento DB and the DB users with the required privileges

To logon on to Percona database server, run the commands below.

$ mysql -u root -p

Then create a database called magento233

mysql> CREATE DATABASE magento233;

Create a database user called magento233user with the new password

mysql> CREATE USER 'magento233user'@'localhost' IDENTIFIED BY 'your pass';

Then grant the user full access to the database.

mysql> GRANT ALL PRIVILEGES ON  magento233 . * TO magento233user'@'localhost';

Finally flush privileges and exit

FLUSH PRIVILEGES;
EXIT;

Step 5: Download and install Magento CE 2.3.3 via composer

Install Composer

Run the following command to check if the composer has already been installed:

$ composer
Composer 1.6.3 2018-01-31 16:28:17

If you can see composer version then you are successfully installed composer. If not please install composer

Download Magento 2, Run the following command in the website root directory or specify directory name

 composer create-project --repository=https://repo.magento.com/ magento/project-community-edition=2.3.3 <install-directory-name>

When prompted, enter your authentication keys. Your public key is your username; your private key is your password

https://marketplace.magento.com/customer/accessKeys/ )

You must set read-write permissions for the web server group before you install the Magento software. This is necessary so that the Setup Wizard and command line can write files to the Magento file system.

Please follow below command;

$ cd /var/www/html/<magento install directory>

$ find . -type f -exec chmod 664 {} \;

$ find . -type d -exec chmod 775 {} \;

$find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +

$ find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +

$ chown -R <magento user>:www-data . 

$ chmod u+x bin/magento

Command line;
This example assumes that the Magento install directory is named magento2ee, the db-host is on the same machine (localhost), and that the db-name, db-user, and db-password are all magento:

$ bin/magento setup:install \
--base-url=http://localhost/magento2ee \
--db-host=localhost \
--db-name=magento233 \
--db-user=magento233user \
--db-password=your password \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exit mobile version