Розгорніть Magento на DigitalOcean за 15 хвилин
Зазвичай розгортання Magento займає близько 1 години 30 хвилин. Щоб зекономити ваш час, ми розробили БЕЗКОШТОВНИЙ застосунок Magento 2 Open Source One-Click App для DigitalOcean.
Переваги Magento 2 Open Source One-Click App для DigitalOcean
Зазвичай розгортання Magento займає близько 1 години 30 хвилин. Щоб допомогти вам зекономити час, ми розробили безкоштовний застосунок для Magento 2 Open Source для DigitalOcean. Тепер установка займає всього близько 15 хвилин, або на 10 хвилин більше, якщо ви обираєте інстанс із демо-даними. Процес настільки простий, що з моменту запуску застосунку у 2020 році ми отримали дуже мало звернень у підтримку, і зараз він працює вже на понад 300 живих інстансах. Це найкраще підтвердження легкості інсталяції та стабільної роботи.
Переваги Magento 2 Open Source One-Click App для DigitalOcean:
* Швидке розгортання (всього 15 хвилин)
* Проста інсталяція (лише декілька простих кроків, детально описаних у гайді)
* Автоматичне встановлення останньої версії Magento Open Source
* Можливість одразу встановити надшвидку Hyva Theme (за наявності ліцензії Hyva Theme)
* Всі стандартні функції Magento доступні одразу після інсталяції
* Переваги хостингу DigitalOcean (зручний інтерфейс, потужні ресурси для відмінної роботи інтернет-магазину)
Переваги DigitalOcean:
* Хороші апаратні ресурси, що забезпечують високу продуктивність інтернет-магазину, та зручні інструменти для роботи
* Доступна ціна у порівнянні з іншими хмарними провайдерами
* Гнучкі серверні конфігурації для будь-яких завдань
* API з усім необхідним функціоналом, простий у використанні інтерфейс
* Підтримка Kubernetes “з коробки”
* Багато дата-центрів по всьому світу
* DigitalOcean Marketplace із зручними рішеннями
Що потрібно для розгортання Magento 2 на DigitalOcean?
Мінімальні вимоги до Droplet:
- 2 vCPU
- 4 GB RAM
- 50 GB SSD
Перейдіть на сторінку застосунку Magento 2 Open Source One-Click у DigitalOcean Marketplace > створіть Droplet з Magento 2 Open Source > дотримуйтесь інструкції “Getting started after deploying Magento 2 Open Source”.
Magento Deployment Guide
1. Create a Droplet and install Magento Open Source app from the Marketplace.
2. After you create a Magento One-Click Droplet, you’ll need to log into the Droplet via SSH to finish the Magento setup.
This prevents the setup wizard from being visible to the internet until you’re ready to complete it. If you try to visit the Droplet’s IP address before logging into the Droplet, you’ll see a DigitalOcean landing page.
From a terminal on your local computer, connect to the Droplet as root.
Make sure to substitute the Droplet’s IP address.
ssh root@use_your_droplet_ip
If you didn't add an SSH key when you created the Droplet, you’ll first be prompted to reset your root password.
3. The interactive script will run the first prompt for your domain or subdomain.
!Note, before entering your domain or subdomain name, it must be configured through DigitalOcean Control Panel or any other DNS provider.
To cancel setup, press Ctrl+C. This script will run again on your next login
--------------------------------------------------
Enter the domain name for your new Magento 2 site.
(ex. example.org or test.example.org) do not include www or http/s
--------------------------------------------------
Domain/Subdomain name:
4. Create a new admin account for Magento 2
Further, you will be asked to enter the proposed data to create a new admin account for Magento 2.
Now, we will create your new admin user account for Magento.
Your Email Address:
Username:
Password: (Note! Your password should be at least 6 characters long with one digit and one Upper case Alphabet)
Further, you will be asked to enter the proposed data to create an admin account for Magento 2.
5. LetsEncrypt configuration
You have the option of configuring LetsEncrypt to secure your new site. Before doing this, ensure you have pointed your domain or subdomain to this server's IP address. You can also run LetsEncrypt certbot later with the command 'certbot'
6. Set up SSL
The next prompt asks if you want to use SSL for your website via Let’s Encrypt.
!Note, before use SSL for your website your domain name must be propagated by DNS, otherwise Let’s Encrypt doesn’t validate it.
You will see the following message:
Would you like to configure SSL (https) for your site using LetsEncrypt (certbot)? Make sure your domain is pointed to this server's IP address. (y/n):
!Note. You can not configure SSL certificate later just using command 'certbot --apache' because Varnish uses the default 80 port. You must open magento_setup.sh file in /opt/digitalocean/ directory and find a section with configure LetsEncrypt certificate to secure your site and run the commands described there to configure the SSL certificate.
7. Terms of Service
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel:
8. Would you be willing to share your email address with the Electronic Frontier Foundation
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:
9. Obtaining a new certificate...
Enabling site default-ssl.
10. Downloading Magento 2... Installing.
11. Select provider and category paths.
Please, select patch provider: 1
Please, select patch category: 1
Select category from the bellow
Patch categories:
- All (51)
- Catalog/Product (10)
- Order/Checkout (7)
- Payments (3)
- Customer (2)
- Other (2)
- Reports (1)
- Inventory (5)
- Shopping Cart (8)
- Price/Tax (2)
- Emails (2)
- Admin (9)
- GraphQL (14)
- Performance (1)
- Web API (1)
- Import/Export (1)
12. Magento 2 Sample Data Installation
Would you like to install Magento 2 Sample Data? This can help you get started if you're new to Magento. (y/n):
13. Provide your authentication keys from Magento Marketplace
Authentication required (repo.magento.com):
Username:
Password:
To get your Public and Private key, you must follow the instructions How to get your authentication keys. Use the Public key as your Username and the Private key as your Password.
14. Hyva theme installation
To install the Hyva Theme, you must fill in your Hyva Theme token and your Project Name.
Would you like to install Hyva Themes for Magento 2? You'll need a valid token from Hyva Themes and your project name. (y/n):
Please enter your Hyva Themes token:
Please enter your Project Name:
After successful installation, you will see the following message:
Installation complete. Access your new Magento site at https://your.domain/ in a browser to continue.
In addition to the package installation, the One-Click also:
● Enables the Apache rewrite module so the Magento 2 permalink feature will work.
● Enables the UFW firewall to allow only SSH (port 22, rate limited), HTTP (port 80), and HTTPS (port 443) access.
● Creates a Magento Mysql user with the necessary permissions and creates Magento database. Note: the Droplet root user will not be prompted for the MySQL password.
● Download and install Magento 2 with Sample Data (optional) instance on your entered domain.
● Install Hyva Theme frontend (optional)
● Enable and configure Varnish (port 80) for your Magento 2 instance.
● Configure Postfix SMTP server. It’s a free and open-source mail transfer agent that routes and delivers electronic mail to your Magento 2 Admin email address
After Installation, you can use the Magento 2 Admin Dashboard
For reference:
● The MySQL Magento user password is in /root/.digitalocean_password.
!Note, the Droplet root user will not be prompted for the MySQL password.
● The web root is /var/www/html.
● You can get information about the PHP installation by logging into the Droplet and running php -i.
● For access Magento admin panel using “Username” and “Password”, which were introduced earlier.
Creating an Apache virtual hosts file for each site maintains the default configuration as the fallback, as intended, and makes it easier to manage changes when hosting multiple sites.
To do so, you’ll need to create two things for each domain: a new directory in /var/www for that domain’s content, and a new virtual host file in /etc/apache2/sites-available for that domain’s configuration. For a detailed walkthrough, you can follow How to Set Up Apache Virtual Hosts.
If you didn’t enable HTTPS during the initial setup script, you can enable it manually at any time after the fact.
Setting up an SSL certificate enables HTTPS on the web server, which secures the traffic between the server and the clients connecting to it. Certbot is a free and automated way to set up SSL certificates on a server. It’s included as part of the Magento 2 One-Click to make securing the Droplet easier.
To use Certbot, you’ll need a registered domain name and two DNS records:
● An A record from the domain (e.g., example.com) to the server’s IP address
● An A record from the domain prefaced with www.example.com to the server’s IP addressAdditionally, if you’re using a virtual hosts file, you’ll need to make sure the server name directive in the VirtualHost block (e.g., ServerName example.com) is correctly set to the domain.
HTTPS traffic on port 443 is already allowed through the firewall. After you set up HTTPS, Varnish configuration will automatically redirect your site to your secure 'https' url.
For a more detailed walkthrough, you can follow How to Secure Apache with Let’s Encrypt or view Certbot’s official documentation.
You can serve files from the web server by adding them to the web root
(/var/www/html) using SFTP or other tools. API Creation
In addition to creating a Droplet from the Magento 2 Open Source 1-Click App via the control panel, you can also use the DigitalOcean API
As an example, to create a 4GB Magento 2 Open Source Droplet in the NYC3 region, you can use the following curl command. You’ll need to either save your API access token to an environment variable or substitute it into the command below.
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer '$TOKEN'' -d \
'{"name":"choose_a_name","region":"nyc3","size":"s-2vcpu-4gb","image":"eltrino-magento2opensour-20-04"}' \
"https://api.digitalocean.com/v2/droplets"
1. Створіть Droplet і встановіть застосунок Magento Open Source із Marketplace.
2. Після створення Droplet з Magento One-Click потрібно підключитися до Droplet через SSH, щоб завершити налаштування Magento.
Це захищає майстер налаштування Magento від доступу в Інтернет, поки ви не будете готові завершити установку. Якщо спробувати перейти за IP-адресою Droplet до входу через SSH, ви побачите стандартну сторінку DigitalOcean.
Підключіться до Droplet як root із терміналу вашого комп’ютера:
```
ssh root@your_droplet_ip
```
(Не забудьте замінити your\_droplet\_ip на фактичну IP-адресу Droplet.)
Якщо ви не додали SSH-ключ під час створення Droplet, спочатку система запропонує скинути пароль root.
3. Після входу запуститься інтерактивний скрипт, перше питання — домен чи субдомен для Magento.
*Зверніть увагу: перед введенням домену або субдомену він має бути налаштований у панелі керування DigitalOcean або в іншого DNS-провайдера.*
Щоб скасувати налаштування, натисніть Ctrl+C. Скрипт знову запуститься під час наступного входу.
Введіть доменне ім’я для нового сайту Magento 2 (наприклад, example.org чи test.example.org, без www або http/https).
4. Створіть новий обліковий запис адміністратора для Magento 2
Вам запропонують ввести email, логін і пароль для створення нового адміністративного користувача Magento.
*Пароль має містити щонайменше 6 символів, одну цифру та одну велику літеру.*
5. Налаштування LetsEncrypt
Ви можете налаштувати LetsEncrypt для захисту нового сайту. Перед цим переконайтеся, що ваш домен уже вказує на цю IP-адресу сервера. Також LetsEncrypt certbot можна запустити пізніше вручну за допомогою команди `certbot`.
6. Включення SSL
Далі система запитає, чи хочете ви використовувати SSL для сайту через Let’s Encrypt.
*Зверніть увагу: ваш домен має бути повністю делегований у DNS до запуску SSL, інакше сертифікат не вдасться підтвердити.*
Щоб налаштувати SSL пізніше, відкрийте файл magento\_setup.sh у /opt/digitalocean/, знайдіть секцію з налаштуванням SSL і дотримуйтесь інструкцій у файлі.
7. Прийміть умови використання Let’s Encrypt, погодьтеся або скасуйте (A — погодитись, C — скасувати).
8. Вас запитають, чи погоджуєтесь ви поділитися своєю електронною адресою з Electronic Frontier Foundation (Yes/No).
9. Отримаєте новий сертифікат, увімкнеться сайт із SSL.
10. Magento 2 завантажується й встановлюється.
11. Виберіть провайдера патчів і категорію, якщо потрібно.
12. Встановлення демонстраційних даних Magento 2 (Sample Data). Якщо потрібно, підтвердіть установку.
13. Введіть ключі автентифікації з Magento Marketplace (Public key — Username, Private key — Password).
14. Встановлення Hyva Theme
Для встановлення Hyva Theme потрібно ввести токен Hyva і Project Name.
Після успішної установки ви побачите повідомлення:
> Installation complete. Access your new Magento site at [https://your.domain/](https://your.domain/) у браузері для подальшої роботи.
Додатково One-Click застосунок:
* Вмикає модуль Apache rewrite для підтримки посилань Magento 2
* Вмикає брандмауер UFW (SSH — порт 22, HTTP — порт 80, HTTPS — порт 443)
* Створює користувача та БД MySQL для Magento
* Завантажує та встановлює Magento 2 із демонстраційними даними (опційно)
* Встановлює Hyva Theme (опційно)
* Вмикає та налаштовує Varnish (порт 80) для Magento 2
* Налаштовує Postfix SMTP для надсилання email з Magento
Після встановлення використовуйте Magento 2 Admin Dashboard:
* Пароль користувача MySQL для Magento знаходиться у /root/.digitalocean\_password
* Веб-корінь сайту — /var/www/html
* Інформацію про PHP можна отримати через команду `php -i` у Droplet
* Для входу в адмінпанель Magento використовуйте задані під час установки Username і Password
Якщо ви не ввімкнули HTTPS під час первинного налаштування, можете це зробити пізніше вручну. Certbot уже встановлений для спрощення процесу отримання SSL-сертифіката.
Щоб використовувати Certbot, потрібен домен і два DNS-записи (A-запис для example.com і для [www.example.com](http://www.example.com), обидва на IP сервера). Також переконайтеся, що в Apache VirtualHost вказано правильний ServerName.
Після налаштування HTTPS весь трафік автоматично перенаправляється на безпечний [https://-URL](https://-URL).
Файли для вебсайту можна розміщувати у /var/www/html через SFTP чи інші інструменти.
**API для створення Droplet**
Окрім створення Droplet через панель DigitalOcean, це можна зробити через API.
Наприклад, щоб створити 4GB Droplet із Magento 2 Open Source у регіоні NYC3:
```bash
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer '$TOKEN'' -d \
'{"name":"choose_a_name","region":"nyc3","size":"s-2vcpu-4gb","image":"eltrino-magento2opensour-20-04"}' \
"https://api.digitalocean.com/v2/droplets"
```
Не забудьте використати власний API-токен для авторизації.