How to install Magento Open Source on Ubuntu 16.04

INSTALL GUIDE. APACHE UBUNTU
INSTALL GUIDE. APACHE UBUNTU

install Magento, Open Source is a flexible e-trade platform for developers and small corporations. The loose open source edition comes with the performance and features to satisfy the requirements of the groups of these days. It is the best platform for developing small business web sites or all people who wishes to research and experiment with constructing a web keep.

install Magento Open Source

install Magento,Deploying a cloud server

If you have not already registered with UpCloud, you should start by getting signed up. Take a moment to create an account and then you could without difficulty install your own cloud servers.

Once you have signed up, log into your UpCloud manage panel and set up a server.

Deploy a new cloud example for web hosting the Magento website online, select an availability sector of your selecting and the Ubuntu sixteen.04 from the Public Templates. You can find in-depth instructions on all the configuration alternatives at the manual for how to installation a server.

Upgrading the Magento programs and extensions can require up to 2GB of RAM to complete an upgrade correctly. For the excellent effects, you should choose a configuration with at least the encouraged 2GB of system reminiscence.

Installing prerequisites

Running a Magento web page requires a fundamental web server functionality to function. More specifically, you will need to install at least an internet service like Apache2 or nginx, a database which includes MySQL or MariaDB, and a PHP script preprocessor, or in other phrases, a LAMP stack.

In this section, you’ll discover streamlined commands for satisfying every of these requirements with the aid of installing Apache2, MariaDB, and PHP.

install Magento,Apache2

Start by means of putting in Apache2 directly from the default repositories with the command underneath.

sudo apt-get install apache2 -y

Once hooked up, you need to allow rewrite for Magento to paintings efficaciously.

sudo a2enmod rewrite

Then create a new configuration record for the Magento Open Source web page by way of beginning a textual content editor with the following command.

sudo nano /etc/apache2/sites-available/magento2.example.com.conf

Enter the instance configurations to the record, then keep and go out the editor.

<VirtualHost *:80>
   ServerAdmin [email protected]
   DocumentRoot /var/www/html/magento2/
   ErrorLog /var/www/html/magento2/error.log
   CustomLog /var/www/html/magento2/access.log combined
   <Directory /var/www/html/magento2/>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
   </Directory>
</VirtualHost>

Next, disable the default web site and permit your Magento configuration.

sudo a2dissite 000-default.conf
sudo a2ensite magento2.example.com.conf

Create the following directory for the site.

sudo mkdir /var/www/html/magento2

Then restart Apache.

sudo systemctl restart apache2

With the first of the conditions installed, maintain to the next step to install the database.

install Magento,MariaDB

MariaDB is a famous open supply alternative to the MySQL database server. It is available on Ubuntu default repositories, however for the present day version, you will want to feature their personal repo to your assets listing with the commands underneath.

sudo apt install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb http://mirrors.coreix.net/mariadb/repo/10.2/ubuntu xenial main'

Once you have imported the key and introduced the repository, you need to update your sources after which install MariaDB. When putting in the database, the installation script will ask you to set a password for the database, create a password for the basis user whilst brought about.

sudo apt update
sudo apt install mariadb-server -y

When the database install is complete, you may need to configure MariaDB with a database for the Magento deploy.

Log into your database server the usage of the root user and the password you put for the duration of the set up. Enter the subsequent command to get to the MySQL command set off.

mysql -u root -p

Enter the following commands in the order shown to create a database instance named magento2with username magento with the same for the password.

MariaDB [(none)]> create database magento2;
MariaDB [(none)]> GRANT ALL ON magento2.* TO [email protected] IDENTIFIED BY 'magento';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Using the exit command will quit the database patron and go back to the normal terminal.

Verify that the database changed into created effectively and that the new person is capable of get entry to it. Use the command beneath at the side of the password set to the user to log into the database.

mysql -u magento -p

Granted the database opened, exit the command prompt like earlier than.

MariaDB [(none)]> exit

In case you get any errors, repeat the previous instructions in the database command activate on the root user and try once more.

install Magento,PHP 7.0

The last part of the LAMP stack is the hypertext preprocessor or PHP in this situation. Magento additionally requires a number of additional PHP applications. Install PHP 7.0 along with all of the wanted extras using the alternatively lengthy command below.

sudo apt install php7.0 php7.0-curl php7.0-mysql libapache2-mod-php7.0 \
php7.0-bcmath php7.0-curl php7.0-gd php7.0-intl php7.0-mbstring php7.0-mcrypt \
php7.0-soap php7.0-xml php7.0-xsl php7.0-zip php7.0-json php7.0-iconv -y

Once all of the PHP applications had been established, you have to make more than one brief adjustments to the configuration files.

Open the first file with the command beneath.

sudo nano /etc/php/7.0/cli/php.ini

Find the row that defines the max_execution_time and set the fee to a hundred and eighty like below, then shop and go out the editor.

max_execution_time = 180

Use the next command to open the other configuration record.

sudo nano /etc/php/7.0/apache2/php.ini

It may also incorporate a max_execution_time that should be set to a bit better fee.

max_execution_time = 180

In the equal file, you will find a memory_limit that may be extended thus relying in your cloud server configuration. For instance, at the primary 2GB preconfigured example you ought to set the memory_limit to 1024M.

memory_limit = 1024M

Afterwards, shop the modifications and go out the editor.

With the PHP configured, your LAMP stack is then equipped to host Magento Open Source. Continue beneath with the instructions to downloading and setting up your e-trade site.

Downloading Magento

Magento is available for down load in a couple of versions and via multiple channels. The open source model can be downloaded either manually from Magento’s product documents or from their GitHub repository. You also have the choice to down load the Magento supply with ready-to-pass sample facts blanketed to get an instance website up and running in no time at all.

Regardless of the technique used to down load Magento programs, you will need to start by using registering and logging right into a Magento account.

Once you have got registered with Magento, start off the server facet configurations via growing a brand new user for jogging Magento with out root priveledges.

sudo adduser --disabled-password --gecos "" magento
sudo adduser magento www-data

Then pick out the choice for downloading Magento you wish to apply and hold under.

Option 1. Manually with Access Token

Log into your Magento account and go to the Download Access Token beneath Account Settings menu. There you’ll discover your Magento ID and the get right of entry to token options which can be used to download Magento packages on the command line.

Click the link to Generate new token.

Then use the subsequent command to check the to be had Magento downloads whilst replacing the and along with your credentials.

curl -k https://<ID>:<TOKEN>@www.magentocommerce.com/products/downloads/info/filter/version/2.*

You can down load any particular file using the right route and filename, as an instance …/downloads/document/Magento-CE-2.1.9.Tar.Gz for that model with out pattern information.

Download the package model you wish, e.G. With the sample records the use of the command below.

curl -k -O https://<ID>:<TOKEN>@www.magentocommerce.com/products/downloads/file/Magento-CE-2.1.9%2BSamples.tar.gz

When the download finishes, create a listing for the documents and extract the bundle.

mkdir ~/magento2
tar zxvf ~/Magento-CE-2.1.9%2BSamples.tar.gz -C ~/magento2/

Then copy the files to the web server directory.

sudo cp -R ~/magento2 /var/www/html/

With the Magento downloaded and copied over, leap forward to the next phase to hold configuring the web page.

Option 2. Using Composer and GitHub

Magento Open Source is likewise to be had for download at the GitHub which might be a preferred alternative, especially to developers. To use the Magento GitHub repository, you’ll want to put in and setup Composer.

Download and installation Composer with the following command.

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

You may even need to create a folder for Composer inside the Magento consumer’s domestic directory.

sudo mkdir /home/magento/.composer

Next, log into your GitHub account and create a new Access token. You can locate commands for a way to do that on the GitHub assist article.

Leave the page open along with your get right of entry to token for the moment and log into your Magento account. Open the Marketplace tab and click on Access Keys section.

On the Access Keys web page, click on the button to Create a New Access Key, provide the important thing pair a call and then click OK.

Magento developer documentation has extra commands for the usage of your Access Keys.

Once you’ve got generated each your GitHub get admission to token and Magento get right of entry to keys, create a new record in the Composer directory called auth.Json.

sudo nano /home/magento/.composer/auth.json

Enter the subsequent statistics while changing the with the get entry to token in your GitHub account and the Magento public and private keys respectively.

{
   "github-oauth": {
      "github.com": "<github-token>"
   },
   "http-basic": {
      "repo.magento.com": {
         "username": "<magento-public-key>",
         "password": "<magento-private-key>"
      }
   }
}

Save the file and go out the editor, then restore the report possession of the .Composer directory.

sudo chown magento:magento -R /home/magento/.composer

You are then geared up to clone the repository, change into the HTML root listing.

cd /var/www/html

Check that you have git installed.

sudo apt install git

Then clone the repository with the command under.

sudo git clone https://github.com/magento/magento2.git

Update the listing possession.

sudo chown www-data:www-data -R /var/www/html/magento2

Next, switch to the magento user.

sudo su magento

Change into the Magento site directory.

cd /var/www/html/magento2

Then use Composer to install the website online.

composer install

Once finished, preserve to the closing a part of this guide to finalize the Magento set up.

Configuring the Magento install

The final part of installing Magento Open Source is to configure the site admin and some other to be had options. This can be completed either on command line or following the install wizard in an internet browser.

Before maintain, double check that the Magento set up directory has the proper permissions. Change into the website listing.

cd /var/www/html/magento2

Make sure the web server has the possession over the files.

sudo chown -R www-data:www-data .

Then set the following permissions in line with each document and folder.

sudo find . -type d -exec chmod 775 {} \;
sudo find . -type f -exec chmod 664 {} \;

These permission updates may take a moment to method because of the number of documents and folders, especially with pattern information included.

Next, add the indexing cron jobs shown beneath to the magento user’s crontab. Open the crontab in an editor with the command beneath.

sudo crontab -u magento -e

Choose the editor you wish to apply, then reproduction the following traces to the report, keep and exit.

* * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run | grep -v 'Ran jobs by schedule' >> /var/www/html/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/bin/magento setup:cron:run >> /var/www/html/magento2/var/log/setup.cron.log

Finally, restart Apache to apply all the changes.

sudo systemctl restart apache2

As stated above, you’ve got two alternatives for finalizing the Magento Open Source installation; in internet browser guided wizard or a command line configuration tool. Continue below with the method you opt for.

Option 1. In browser configurations

Once all of these are set, you may hold on your internet browser by using establishing your cloud server’s public IP or area. You can discover your server’s IP addresses for your UpCloud control panel beneath Network menu.

http://<public IP>

Follow the instructions offered in the set up wizard to installation the web page.

  1. Start with the aid of going for walks the readiness assessments, the effects ought to show all green.
In browser configurations

2. Enter the database information as configured earlier whilst putting in MariaDB.

In browser configurations

3. Check your site configurations and updated as important. You can set the shop to apply a site when you have one configured for the server. And while the admin default URL is just fine, you may want to exchange it to some thing easier to don’t forget.

In browser configurations

4. Customize your shop with the to be had time sector, foreign money and language options or maintain along with the defaults.

In browser configurations

5. Enter person info for your admin account.

In browser configurations

6. When you’re done with the alternatives, click on the Install Now button to allow the device do its component. This may take a moment.

In browser configurations

Success!
Once completed, you’ll be offered with a summary of your site configurations. The page consists of your website and admin URLs which you might need to bookmark for later.

In browser configurations

After efficiently putting in Magento Open Source, disable write access to the following directory with the command below for safety functions.

sudo chmod -w /var/www/html/magento/app/etc

Option 2. Command line configurations

Alternatively, you may make the closing configurations also at the command line with the help of the magento tool in the …/magento2/bin/ directory.

First, make the record is executable with the subsequent command.

sudo chmod +x /var/www/html/magento2/bin/magento

You can test the available configuration alternatives over at Magento developer documentation for command line install.

The following instance command consists of the minimal parameters to get the website online mounted. Replace the along with your server’s public IP cope with or area call when you have one. You can locate your server’s IP addresses in your UpCloud manipulate panel under Network menu.

/var/www/html/magento2/bin/magento setup:install --admin-firstname="admin" --admin-lastname="admin" --admin-email="[email protected]" --admin-user="magento" --admin-password="magento2" --db-user="magento" --db-password="magento" --base-url="http://<public IP>"

The set up will take a second.

Once completed, you will see an output similar to the only underneath confirming the set up and showing your admin URL.

[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_148ohr

For safety, remove write permissions from the following directory with the command beneath.

sudo chmod -w /var/www/html/magento2/app/etc

Then restart Apache and your web page could be to be had for trying out.

sudo systemctl restart apache2

If you have got issues establishing the site, rerun the following command to ensure the internet server has get right of entry to rights to the whole /magento2 listing.

sudo chown -R www-data:www-data /var/www/html/magento2

Summary

Congratulations! You must now have a fully purposeful Magento Open Source e-trade website online up and going for walks.

Magento boasts the most important and most lively network of builders and merchants within the world. Developers percentage innovative thoughts, assist every other, and collaborate to enhance the competencies and overall performance of the Magento Open Source platform. With the help of the complete documentation available for Magento, you may effortlessly be a part of the network to start designing your own commerce extensions or construct the next hit marketplace.