Check this Out!Visit our social network pages for recent updates!

Student questions – How to Install Magento eCommerce App on Ubuntu

Magento is an open source eCommerce application based on PHP that allows webmasters to operate a fully functional web store front. It was bought by eBay, Inc and has strong support base.

It runs on top of the LAMP stack and if you plan to run an ecommerce blog or website, you may want to test drive Magento. This brief tutorial shows you how to easily install Magento on Ubuntu 16.10.

Magento helps independent sellers sell their stuff online and engage with their customers easily. It’s great software for online sellers. The steps below show students and new users how to correctly install Magento on Ubuntu systems.

Like many open source application Magento runs on the LAMP stack. The LAMP stack is an acronym for Linux, Apache2, MySQL and PHP. These open source applications allow for feature-rich online applications like WordPress, Drupal, Joomla and Magento to function.

When you’re ready install Magento, continue below.

Step 1: Install the LAMP stack

As mentioned previously, Magento relies on the LAMP stack to function. To install the stack, reference the link below:

https://websiteforstudents.com/question/install-lamp-stack-ubuntu-server/

Or you can type a single line command below to install LAMP. The commands below install LAMP standard packages which may work for most PHP based applications.

To install it, run the commands below

sudo apt-get update
sudo apt-get install lamp-server^

During the installation, you’ll be prompted to create a root password for MySQL server. Type and confirm the password to continue.

Ubuntu MySQL password prompt screen

Step 2: Create Magento MySQL database and user

After installing LAMP above, logon to MySQL database by running the commands below

mysql -u root -p

Then type the SQL statements below to create a new database called magento

CREATE DATABASE magento;

After that, type the statements below to create a magento user called magentouser with a password

GRANT ALL ON magento.* TO 'magentouser'@'localhost' IDENTIFIED BY 'type_new_password_here';

Next, save and exit

FLUSH PRIVILEGES;

exit

Step 3: Download Magento Files

At this point, you should have LAMP installed and Magento database and user created. Next, follow the steps below to download Magento files. At the time of this post, the latest Magento was 2.1.2

Before you can download and install Magento, you must register for a free account. To do that, click the link below to go to the download page and register.

https://magento.com/tech-resources/download

After downloading the file, run the commands below from the downloaded directory to unzip the download file and copy it to Apache2 default root directory.

sudo unzip ~/Downloads/Magento*.zip -d /var/www/html

Don’t forget to delete Apache2 default test html file in its root directory.

sudo rm -rf /var/www/html/index.html

Next, change the root directory permission so Magento can function properly.

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

sudo chmod -R 755 /var/www/html

Restart Apache2 webserver by running the commands below.

sudo systemctl restart apache2

After that, open your browser and browse to the server hostname or IP address followed by /setup and you should see Magento setup page.

http://192.168.1.1/setup/

When you’re there click the wizard button to begin the readiness check.

magento ubuntu install

On the next page, you’ll see if all the requirements are met. If not, you may install these PHP modules to complete the process.

sudo apt-get install php-curl php-mcrypt php-xml php-xsl php-intl php-mbstring php-zip php-gd

After installing the PHP modules above, reload apache2 server

sudo systemctl reload apache2

Then time all should check out as completed.

magento ubuntu installation

Go to the next page type the database info you created earlier and continue.

magento database connection

Finally, create an admin account that will be used to manage the site.

magento admin account

After all that, click Install and Magento should be installed on your Ubuntu machine.

magento install ubuntu

At this point everything should be installed and ready. If you run into 404 error when navigating the pages, follow the guide below to fix.

Open Apache2 default site configuration file by running the commands below

sudo nano /etc/apache2/sites-available/000-default.conf

Then add these lines in the middle of the file and save.

<VirtualHost>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Then run the commands below to enable Apache2 Mod rewrite.

sudo a2enmod rewrite

Restart Aapche2 and you should be all set!

sudo systemctl reload apache2

Enjoy!