Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Install Magento on Ubuntu 18.04

In this post, we will Install Magento on Ubuntu 18.04.  Magento is an awesome eCommerce platform that highly extendable.

There are several different flavors of Magento.  For the purposes of this post, we will be installing the free open-source version.

This post will cover installing Magento on a non-secure web Server (HTTP).  This is not recommended for production deployments.

For production you will need to configure HTTPS with SSL Certificates.

To download Magento we have to go to their website and register first.

This is most easily done on another system since Ubuntu Server doesn’t have a GUI.

After we download it we can then use SCP or FTP to get the file onto our server.

Downloading Magento Open Source

First thing you should do is point your browser to the Magento Website.

https://magento.com/products/magento-open-source

Once there click on the Get Started button.

Scroll down the page and click on the Download Open Source button.

At the time of this writing the latest stable version is 2.2.5.

For Select your format, select Magento Open Source 2.2.5 with Sample Data.tar.gz.

Next, click the Download button.

In the next window create a new account.

After creating a new account you will need to verify your email.

Next, you will receive an email with a link to verify your email address.

After you click the link you will be sent to a page that will tell you click another link.

Finally, click that link and your download will automatically start.

After you download the file to another system, we are ready to prepare our Magento Server.

Preparing Ubuntu Server

We need to start with a fresh installation of Ubuntu Server 18.04 and install all the updates.

apt update && apt upgrade -y

After the updates are finished reboot to let any new kernels take effect.

reboot

Magento is essentially a PHP application so we need to install a LAMP stack to host the Magento PHP application.

Install Apache, MySQL, and PHP

Run this command to install the Apache 2 Web Server, MySQL:

apt install apache2 mysql-server

Magento requires PHP 7.1 but only 7.2 is available on Ubuntu 18.04.

We will use a custom PPA to install PHP 7.1.

add-apt-repository ppa:ondrej/php
apt update

Next we need need to install PHP 7.1 and the required dependencies for Magento.

apt install php7.1 libapache2-mod-php7.1 php7.1-mcrypt php7.1-xml php7.1-zip php7.1-mysql php7.1-gd php7.1-soap php7.1-intl php7.1-bcmath php7.1-mbstring php7.1-curl

Now we need to secure our MySQL Server installation.  Run the following command.

mysql_secure_installation

Press No for validate password plugin then enter the root password you want to use for MySQL.

For the rest of the questions answer Yes.

Next tell Apache to automatically load PHP files first.

Open the /etc/apache2/mods-enabled/dir.conf file and change it to have index.php listed first.


        DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

Save the file and exit.

Next we need to adjust our PHP configuration so that we can successfully install Magento.

Open the /etc/php/7.1/apache2/php.ini and find the max_execution_time setting.

Change it to 1800 which is 30 minutes.

max_execution_time = 1800

Save and exit the file.

Enable Apache Rewrite Module

We need to enable the Apache Rewrite Module for Magento to work properly.

a2enmod rewrite

Finally, restart the Apache 2 web server.

systemctl restart apache2

Now we are ready to install Magento.

Installing Magento

Next, copy the downloaded file from your system to your new Magento server.

I used SCP to do this but you can also use FTP but you have to configure FTP first.

I copied it to the home directory of my regular user.

I then copied it over to the root users home after sudoing to the root user.

sudo su -
cp /home/admintome/Magento-CE-2.2.5_sample_data-2018-06-26-09-42-59.tar.gz .

Next, create a magento directory.

mkdir magento
mv Magento-CE-2.2.5_sample_data-2018-06-26-09-42-59.tar.gz magento/
cd magento/

Now that we have the file where we want it, we need to untar it.

tar -xzvf Magento-CE-2.2.5_sample_data-2018-06-26-09-42-59.tar.gz

Remove the archive.

rm Magento-CE-2.2.5_sample_data-2018-06-26-09-42-59.tar.gz

All of our web server files are served from the /var/www/html directory.  We need to move our extracted files to that directory.

mv * /var/www/html

Next, we need to change the ownership of the files so that the web server can read them.

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

Open the /etc/apache2/sites-enabled/000-default.conf file and add this section before the closing tag?

        
                AllowOverride All
                Order allow,deny
                Allow from all
        

Save and exit the file.

Next create a new file /var/www/html/.htaccess and add the following content.



############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

    #RewriteBase /magento/

############################################
## uncomment next line to enable light API calls processing

#    RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

############################################
## rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^api/rest api.php?type=rest [QSA,L]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## redirect for mobile user agents

    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

Save and exit the file.

Now we need to create the database that Magento will use.

Create the Magento Database

Start the MySQL CLI.

mysql -u root -p

Enter the password you created earlier during the mysql_secure_installation.

Create the database.

mysql> CREATE DATABASE magento DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Next, create the Magento database user.

mysql> GRANT ALL ON magento.* TO 'magento'@'localhost' IDENTIFIED BY 'password';

Be sure to update the password to something more secure.

Flush the privileges so that MySQL knows about the changes.

mysql> FLUSH PRIVILEGES;

Finally, we need to exit the MySQL CLI.

mysql> EXIT;

We are now ready to start the Magento Setup Wizard.

Magento Setup Wizard

Browse to the following URL to start the Setup Wizard.

http://{your_server}/setup

You will see the setup screen.

Click on Agree and Setup Magento.

Next click on Start Readiness Check.

You should see that all the checks pass.

Click the Next button to continue.

We now have to enter in the database information.

Enter in the same information from earlier when we created the database in MySQL.

Click on the Next button to continue.

The next screen displays the web information.  Take note of the admin address and click on Next.

In the next screen you have the option to customize your store.  Select the options you need then click on Next.

Enter in the administrator account details in the next screen then click on Next.

Finally click on the Install Now button to finish the installation.

The installation will take several minutes to complete since we included the sample data.

When it is completed you will see the success screen.

Click the Launch Magento Admin button to finish.

You will see the administrator login.

You can now also access you store by browsing to your server’s IP address or DNS name.

Welcome to the beautiful world of ecommerce!

Conclusion

Installing Magento is a little bit involved but once you have it running you have a solid ecommerce solution.

If you enjoyed this post or if you found it helpful please share it and comment below.

Click here for more great Ubuntu HowTo articles from AdminTome Blog.

The post Install Magento on Ubuntu 18.04 appeared first on AdminTome Blog.



This post first appeared on AdminTome, please read the originial post: here

Share the post

Install Magento on Ubuntu 18.04

×

Subscribe to Admintome

Get updates delivered right to your inbox!

Thank you for your subscription

×