I want know, how I install magento on my Ubuntu with Nginx.
Thanks.
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!
Hello,
There are two ways to go about this now,
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.
To install Magento on Ubuntu with Nginx, follow these steps:
Update and upgrade your system:
- sudo apt update
- sudo apt upgrade
Install required packages:
- 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:
- sudo apt install mysql-server
After installing MySQL, run the following command to secure the installation:
- 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:
- 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:
- 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:
- wget https://github.com/magento/magento2/archive/refs/tags/2.4.3.zip
Unzip the downloaded file:
- unzip 2.4.3.zip
Move the Magento files to the desired web directory (e.g., /var/www/magento
):
- sudo mkdir -p /var/www/magento
- sudo mv magento2-2.4.3/* magento2-2.4.3/.htaccess /var/www/magento
Set the correct permissions:
- sudo chown -R www-data:www-data /var/www/magento
- sudo chmod -R 755 /var/www/magento
Configure Nginx:
Create a new Nginx configuration file for Magento:
- 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:
- 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.
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.