• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
logo

Tutsplanet

Free Technical and Blogging Resources

  • Home
  • Web Hosting
  • Programming
  • Plugins
  • Write For US
  • News
  • About Us
  • Tools
You are here: Home / Magento / How to Install Magento 2.3 & Create a Web Server-LAMP

How to Install Magento 2.3 & Create a Web Server-LAMP

Jun 2, 2020 by Editorial Staff 1 Comment

This tutorial demonstrates how to install Magento 2.3 and build a web server on operating system Ubuntu 16.04 LTS.

In this tutorial I have used Digital Ocean droplet (2GB instance), you may please create the same or you can install one in your PC.

First we create a user apart from root user, as it is not advisable to share root user for all the people works in the project.

adduser tutsplanet

Add the user to sudo group, so they will have the super user access as root(Super User).

usermod -aG sudo tutsplanet

Disable the root user for added security

Access the following config file to access the ssh configuration and disable root login.

sudo nano /etc/ssh/sshd_config

Use the arrow keys to navigate through the configuration file, and find a text like this PermitRootLogin yes. Change this value to no.

Now reload the ssh configuration using the below command

sudo systemctl reload sshd

Enable Basic Firewall

As we using ssh connections, we need to allow this in the firewall.

sudo ufw allow ssh
sudo ufw enable  //turn on the firewall

You will get a disconnecting warning on the screen, just hit Y and go to the next command.

 

Now we are almost there to install Magento 2.3

The basic PHP version is coming with 16.04 version is PHP 7.0, but here we need at least 7.2 for the version of Magento we are using.

So we use a well know PHP repository that have the latest PHP versions, to add repo, just use the below command.

sudo add-apt-repository ppa:ondrej/php

Now we need to download/update the records from the connected repositories, run the below command.

sudo apt-get update

Install Apache

Use the below command to install Apache server . The -y added in the command will skip the confirmation question.

sudo apt-get install apache2 -y

Now open Apache configuration file and add the below snippet at the below of the all content. This will enable .htaccess rules required for Magento

sudo nano /etc/apache2/sites-available/000-default.conf
<Directory "/var/www/html">
    AllowOverride All
</Directory>

Open Apache settings file to set the Global ServerName

sudo nano /etc/apache2/apache2.conf

Add this line at the end of the file, then save and exit

ServerName <server_IP>

Check for any errors

sudo apache2ctl configtest

Enable Apache rewrite

sudo a2enmod rewrite

Restart Apache for any changes to take effect

sudo systemctl restart apache2

Enable Apache through the firewall

sudo ufw allow 'Apache Full'

Now just hit the IP address of server in the browser, you will see the Apache welcome page.

Installing PHP and extensions

Let’s start by installing PHP and all of the PHP extensions required in order for Magento 2.3 to run

Run the below command to install all the necessary extensions of PHP for Magento 2.3

sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-soap php7.2-bcmath php7.2-xml php7.2-mbstring php7.2-gd php7.2-common php7.2-cli php7.2-curl php7.2-intl php7.2-zip zip unzip -y

Move the index.php as the first in the below file, to serve the PHP as first option

sudo nano /etc/apache2/mods-enabled/dir.conf

Restart apache for changes to take effect

sudo systemctl restart apache2

Install MySQL and secure the installation

Make sure that your MySQL root password password is:

  • Longer than 16 characters
  • Contains numbers
  • Contains lower & uppercase characters
  • Contains special characters

Now, it’s time to install and configure MySQL. MySQL is a database management system that allows the web server to store information that can be accessed by Magento.

Install MySQL

sudo apt-get install mysql-server -y

Run a MySQL security script that addresses some vulnerabilities

sudo mysql_secure_installation

Install phpMyAdmin and secure the installation

Important Note

Make sure your PhpMyAdmin password have the following otherwise you cannot login to PhpMyAdmin even if your password is correct.

  • Contains numbers
  • Contains lower & uppercase characters
  • Contains special characters

Help: PhpMyAdmin login issue

Install phpMyAdmin

sudo apt-get install phpmyadmin php7.2-mbstring php7.2-gettext -y

Make sure that you select apache2 using your SPACE BAR before hitting ENTER to continue. Restart Apache for any changes to take effect

sudo systemctl restart apache2

Test Your PHPMyAdmin
Go to the browser and hit the url http://<SERVERIP>/phpmyadmin, you should see the Phpmyadmin

Magento Installatiion

We are now reached our actual goal of these all setup, the real Magento installation.

Create a magento user

The reason for creating a new user is for added security.The main user tutsplanet have all the super user permissions.

sudo adduser magento

Make the web server group the primary group for the new user

sudo usermod -g www-data magento

Folder permissions

When we installed Apache in , it automatically created a web directory to store own web files. However, it will have created this under the default user known as www-data. So, we just need to update the folder permissions for the directory where we installing Magento. This will allow our new Magento user to operate correctly.

Update the root file ownership to coincide with our new web user

sudo chown magento:www-data /var/www/html/

Magento Access Keys

Before you do anything else, be sure to visit https://marketplace.magento.com 317 and create an account. Then you can generate a set of access keys that will allow you to download from the Magento repository via Composer.

Install Composer

Now that we have our keys, we’re ready to install Composer.

Install Composer by downloading the file direct from their website

sudo curl -sS https://getcomposer.org/installer | php

Move composer file to the required directory

sudo mv composer.phar /usr/local/bin/composer
Important Note

When you installing using composer, you might face memory issue with composer. First instance, I thought it’s php memory limit and increasing php memory limit did not help me. But adding  as swap drive helps me to get the magento installation run smoothly. Please follow this tutorial if your Ubuntu installation not having the Swap partition. If you have please ignore this.

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04

Download Magento 2.3 via Composer

Navigate to your web root

cd /var/www/html

now switch to Magento user

su magento

Remove whatever files residing in the folder.

Next, run the below command to install the Magento in your current working directory. Please note the dot at the end of the command.

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .

During the setup, you will be asked for a Username and a Password. Just to be clear, Username = Public Key and Password = Private Key what we created on the Magento website. This process will take roughly 5 minutes to complete – So I will skip forward…

Set pre-installation permissions

We should not miss this step, as this will cause run time errors in your magento installation like 500.

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 :www-data . && chmod u+x bin/magento

Create Database

visit HTTP://<SERVERIP>/phpmyadmin and create a database.

Install Magento via web setup wizard

Hit the url http://<SERVER_IP>/setup in the browser, there your Magento installation starts. Fill the details when the text fields comes on the screens

One last step

Edit your .htacess

nano .htaccess

Replace 756MB with 2G in the .htacess to avoid memory isssues in the installtion.

Install cron tasks

bin/magento cron:install

Now your magento is all ready for hacking.

 

Helpful Articles

Enable Query Cache to improve performance

PHPMyadmin not found

More about Magento 2 Folders/Files Permissions


Editorial Staff

Editorial Staff at Tutsplanet is a dedicated team to write various tutorials about subjects like Programming, Technology and Operating Systems.

View all posts by Editorial Staff

Filed Under: Magento, Programming Tagged With: Hosting, Magento 2

Reader Interactions

Comments

  1. Website design in Oakville says

    Sep 29, 2020 at 10:19 pm

    Magnificent resourceful information. I actually like what I’ve
    acquired here. You make your site content enjoyable and easy to grasp.
    a
    I can’t wait to read more from you. Bookmarked!

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar




Quick Links

  • A Simple YouTube Video Downloader Script in PHP
  • The 50 Most Useful jQuery Plugins for Frontend Development
  • Word Set 01
  • Convert PNG to JPG Online

Subscribe

* indicates required

Share

   

Hot topics

  • A Simple YouTube Video Downloader Script in PHP 13.3k views
  • Open a URL in a new tab using JavaScript 10.7k views
  • Using Third-Party Libraries in Codeigniter 8.4k views
  • Add FTP/SFTP in Visual Studio Code 6.1k views
  • Replace “\n” with new line characters, using Notepad++ 4.8k views
  • Manually Install APK Files In Android Studio Emulator 4.7k views
  • Upload Multiple Images and Store in Database using PHP and MySQL. 4.5k views
  • How To Install And Use CKEditor In Laravel? 4.2k views
  • Simple PHP Shopping Cart 4k views
  • Spout, an awesome library for reading and writing in Excel. 3.3k views

Categories

  • Design & Development
  • Drupal
  • Facebook
  • General
  • How To
  • ios
  • Javascript
  • Linux
  • Magento
  • Marketing
  • News
  • PHP
  • Plugins
  • Programming
  • Snippets List
  • Social Media
  • Softwares
  • Themes
  • Tips
  • Wordpress
  • YouTube

Copyright © 2021 · TutsPlanet Gene Theme on Genesis Framework · Powered By BunnyCDN