Instalare magazin online NopCommerce(open source) pe Linux
NopCommerce este un magazin open source scris in C# cu ASP.NET MVC Core, suporta crearea de teme personalizate, exista un marketplace cu teme free si contracost, si poate folosi ca baze de date SQL Server, MySQL sau PostgreSQL.
Magazinul are suport pentru mai multe limbi, monede, inclusiv romaneasca. Am instalat magazinul NopCommerce folosind baze de date SQL Server, MySQL, dar am ales pentru acest tutorial MySQL, in speranta ca consuma mai putine resurse decat SQL Server, dar si pentru ca suportul de backup e mai bun in MySQL pe Linux, fiindca e important sa poti muta datele usor de pe un server pe altul fara sa le pierzi.
Acest tutorial se aplica oricarei aplicatii ASP.NET Core, ce trebuie instalata pe Linux, aplicatia ASP.NET Core se instaleaza ca serviciu de linux, systemd, si se foloseste nginx ca server web si reverse proxy.
Magazinul are o sectiune de administrare cuprinzatoare:
Am creat o masina virtuala cu Ubuntu 20.04.6 LTS x86_64 in Microsoft Azure, la care m-am conectat cu ssh folosind ssh user@hostip. Comanda neofecth are output-ul de mai jos:
Se dechid porturile din Microsoft Azure, 22 ssh, 80 http, 3306 mysql, eventual aceste porturi se dechid si din Linux cu ufw.
1.) Instalare .NET Core
Se instaleaza .NET Core pe masina virtuala remote, ruland urmatoarea comanda:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Se conecteaza la server MySQL cu sudo mysql in terminal si se schimba parola de root pentru conectarea la server:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pentru conectare remote, din MySQL Workbench de exemplu, se deschide fisierul de configurare MySQL:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Se editeaza bind-address de la 127.0.0.1 la 0.0.0.0, fisierul de configurare va arata asa:
Se reporneste serverul MySQL pentru a ne asigura ca se incarca configurarea noua:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cu UFW (Uncomplicated Firewall) se deschide portul 3306:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acuma se poate deschide baza de date remote, de pe masina locala, in MySQL Workbench:
3.) Instalare nginx
Se instaleaza pachet nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pentru a configura nginx ca reverse proxy care sa trimita cererile catre aplicatia ASP.NET Core, se modifica /etc/nginx/sites-available/default. Deschide acest fisier intr-un editor text si se inlocuieste continutul cu urmatorul:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Se seteaza timeout la 3000 de secunde ca sa nu dea eroare, pentru task-urile care dureaza mult.
4.) Instalare nopCommerce
Se creaza directorul:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Se creaza cateva directoare necesare rulari nopCommerce:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creaza fisier /etc/systemd/system/nopCommerce.service cu urmatorul continut:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Acuma ca totul este gata, putem incepe sa instalam si sa configuram magazinul.
E important ca baza de date sa nu existe, ea va fi creata la instalare nopCommerce.
Se completeaza connection string in interfata web:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Se apasa buton Install din interfata web si se asteapta.
Si avem magazinul instalat.
Instalarea genereaza fisierul appsettings.json in /var/www/nopCommerce/App_Data, ca sa resetezi instalarea se sterge appsettings.json si va aparea pagina web de Install.
Printre clienti nopCommerce, se numara:
Am testat mai multe Size-uri hardware pentru masina virtuala in Azure si merge bine Standard DS1 v2 (1 vcpu, 3.5 GiB memory), am incercat si cu 1 Gb RAM dar e prea putin pentru MySQL si aplicatie, merge lent.
Comentarii
Trimiteți un comentariu