Installing Magento on Ubuntu 15.04 with LAMP Stack

Magento is a free and open-source e-commerce solution developed by eBay. It typically runs on a LAMP stack across most Linux-based systems. This guide explains how to deploy Magento on Ubuntu 15.04, although the instructions should also work for other Ubuntu versions.

Keep in mind that Magento consumes a significant amount of server resources. While a test environment requires at least 512MB of RAM for PHP, it’s recommended to allocate 1GB for small-scale stores and at least 4GB for medium to large-scale stores managing hundreds of items.

This guide assumes you’re working with a freshly provisioned VPS without any pre-installed packages.

Step 1: Install the LAMP Stack

Start by updating the apt package index to make sure you’re pulling the latest versions:

Once updated, proceed to install the LAMP stack (Linux, Apache, MySQL, PHP) in one command using sudo. Alternatively, each component can be installed individually following a different tutorial:

$ sudo apt-get install lamp-server^

During installation, you’ll be prompted to create a root password for MySQL. Choose a strong password and make sure to save it—you’ll need it later in the setup.

Step 2: Configure Apache

Before Magento can be installed, Apache needs to be configured to handle redirection and URL rewriting. To do this, you’ll create a new virtual host configuration file:

$ sudo nano /etc/apache2/sites-available/magento.conf

Inside the file, add the following configuration block. This example uses the nano editor, but any text editor will work:

<VirtualHost *:80>
    DocumentRoot /var/www/public
    <Directory /var/www/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

The contents should resemble the configuration in the screenshot named 1.png.

Save and exit the file using Ctrl + O to write the file and Ctrl + X to close nano.

Now, enable the new virtual host and disable the default one with the following commands:


$ sudo a2ensite magento.conf


$ sudo a2dissite 000-default.conf

Finally, restart Apache to apply the changes:

$ sudo service apache2 reload

Step 3: Configure PHP for Magento

Since Magento is a high-demand application, the default PHP settings must be adjusted to provide more memory. For this test installation, we’ll allocate 512MB of memory. However, real-world stores generally require between 1GB and 4GB, depending on their size.

Start by opening the php.ini configuration file with a text editor:

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

Within this file, search for the line that defines the PHP memory limit and modify it as shown below:

This adjustment is illustrated in the screenshot labeled 2.png.

Save the file and exit using Ctrl + O followed by Ctrl + X.

Magento also depends on a set of additional PHP modules. You can install all of them at once using the following command:

$ sudo apt-get install php5-mcrypt php5-curl php5-gd libcurl3 php5-intl php5-xsl

After installation is complete, enable the necessary modules with the commands below:


Restart the Apache service to activate the changes:

$ sudo service apache2 restart

Step 4: Prepare MySQL for Magento

Magento uses MySQL to manage all the website’s content and configuration data. A dedicated database must be created for it. Start by launching the MySQL command line using the password set earlier during the LAMP stack setup:

Once you’re in the MySQL shell, run the following SQL command to generate a new database for Magento:

Exit the MySQL prompt by pressing Ctrl + C.

Step 5: Install Magento Using Composer

Begin by installing Composer, a dependency manager for PHP, using the following command:

$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

To access the Magento source code repository, you’ll need to authenticate using a keypair. Please refer to the official Magento Developer Documentation for the most up-to-date steps on generating these keys.

After obtaining the keys, store them in Composer’s authentication file by editing it with the following command:

$ sudo nano /root/.composer/auth.json

Insert the following JSON content, replacing the placeholders with your actual public and private keys:

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

Navigate to your web server’s root directory:

Clone the Magento 2 repository using Git and specify the version branch:

$ git clone -b 2.0 https://github.com/magento/magento2.git public

Once the repository is cloned, enter the Magento directory:

Run Composer to install all required dependencies for Magento:

Step 6: Complete the Installation via Browser

To continue, open your web browser and go to the IP address assigned to your VPS.

Upon visiting the site, you should see the Magento setup wizard. Follow the steps in the browser interface, and be sure to use the database credentials you created earlier in this tutorial.

Conclusion

By following the steps outlined in this tutorial, you’ve successfully set up Magento on an Ubuntu 15.04 server with a full LAMP stack. From configuring Apache and PHP to installing Magento via Composer and finalizing the setup in your browser, your development environment is now ready to explore Magento’s powerful e-commerce features.

Always remember that Magento is resource-intensive. If you’re planning to use it for a live online store, consider optimizing your server environment and scaling up your resources accordingly. Additionally, stay up to date with Magento’s latest updates and security patches to ensure optimal performance and protection.

With your store infrastructure now in place, you’re ready to start customizing your storefront, adding products, and preparing for launch.

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: