Question

How I install Magento on LEMP?

  • Posted on December 12, 2012
  • rpontesAsked by rpontes

I want know, how I install magento on my Ubuntu with Nginx.

Thanks.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
April 25, 2023
Pinned Answer

Hello,

There are two ways to go about this now,

MarketPlace

You can either use a MarketPlace Droplet : https://marketplace.digitalocean.com/apps/magento-2-open-source

The Droplet comes with everything installed and configured for you to use on the GO as soon as you create and SSH to your Droplet.

Manual Installation

To install Magento on Ubuntu with Nginx, follow these steps:

Update and upgrade your system:

  1. sudo apt update
  2. sudo apt upgrade

Install required packages:

  1. sudo apt install nginx php-fpm php-cli php-common php-curl php-gd php-intl php-mbstring php-mysql php-soap php-xml php-xsl php-zip php-json php-opcache php-bcmath unzip

Install MySQL:

  1. sudo apt install mysql-server

After installing MySQL, run the following command to secure the installation:

  1. sudo mysql_secure_installation

Follow the prompts to set a root password and remove anonymous users, disallow remote root login, and remove the test database.

Create a Magento database and user:

Log in to the MySQL shell:

  1. sudo mysql -u root -p

Create a new database and user for Magento (replace magento_user, magento_password, and magento_database with your desired values):

CREATE DATABASE magento_database;
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'magento_password';
GRANT ALL PRIVILEGES ON magento_database.* TO 'magento_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Install Composer:

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

Download Magento:

Download the latest Magento version from the official website or use the following command to download the latest version at the time of writing:

  1. wget https://github.com/magento/magento2/archive/refs/tags/2.4.3.zip

Unzip the downloaded file:

  1. unzip 2.4.3.zip

Move the Magento files to the desired web directory (e.g., /var/www/magento):

  1. sudo mkdir -p /var/www/magento
  2. sudo mv magento2-2.4.3/* magento2-2.4.3/.htaccess /var/www/magento

Set the correct permissions:

  1. sudo chown -R www-data:www-data /var/www/magento
  2. sudo chmod -R 755 /var/www/magento

Configure Nginx:

Create a new Nginx configuration file for Magento:

  1. sudo nano /etc/nginx/sites-available/magento

Paste the following configuration, replacing yourdomain.com with your domain name and adjusting other values as needed:

upstream fastcgi_backend {
    server  unix:/run/php/php7.4-fpm.sock;
}

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    set $MAGE_ROOT /var/www/magento;
    include /var/www/magento/nginx.conf.sample;
}

Save and close the file. Create a symbolic link to enable the configuration:

  1. sudo ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled/
systemctl restart nginx

Then you just need to open your Droplet and start the installation process.

Magento Requires more Resources than usuall

You might need a more powerful droplet if you want to use Magento as the smallest one wouldn’t work, they won’t have enough resources.

Alternatively, you can add SWAP to your Droplet https://www.digitalocean.com/community/tutorial_collections/how-to-add-swap-space

Thanks. I will try this configuration

@ ssalgado <br>Yup ! thnx!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.