Skip to content

How to Install Magento 2 on Ubuntu using Nginx

Step 1: Install nginx

Run the command:

Step 2: Install and configure php-fpm

  1. Install php-fpm and php-cli:

Run the command:

  1. Open the php.ini files in an editor:

Run the following commands:

  1. Make modification in those files to match the following lines:

  1. Save and exit the editor you using
  2. Restart the php-fpm service by using the below command:

Step 3: Install and configure MySQL

  1. Run the following command:

  1. Secure the installation by entering the line:

  1. Test the installation with the command:

  1. You can increase the value for packet which is larger than Magento default by opening /etc/mysql/mysql.cnf in a text editor and navigate to max_allowed_packet.

Then, save to mysql.cnf and restart MySQL by entering service mysql restart.

Run the following command at a mysql> prompt to verify your set value:

  1. Make your Magento database configuration

Install and configure Magento 2

Download your Magento 2 and then we are good to go.

  1. Run the following to change to docroot directory:

  1. Extract the Magento 2 you downloaded and name it magento2/:

  1. Enter the following lines to set directory ownership and file permissions.

  1. Install Composer globally.

  1. Update Magento dependencies:

  1. Enter your Magento authentication keys.
  2. Run the below in command line to install Magento:

Remove http://www.magento-dev.com and add your domain name.

  1. Last but not least, change to developer mode to continue with nginx configuration:

Step 4: Configure nginx

  1. Run the line to create a new virtual host for your Magento site:

  1. Make the following configuration:

  1. Match your domain name with the base URL you chose when installing Magento.
  2. Save and exit the editor.
  3. Activate host by creating a symlink:

  1. Verify if the syntax is correct:

  1. Run the command to restart nginx:

Step 5: Verify the installation

Now try your site’s URL on a web browser to verify the site yourself.

One Comment

Leave a Reply

Your email address will not be published.

Share via
Copy link
Powered by Social Snap