在当今快节奏的数字世界中,开设在线商店从未如此简单。电子商务平台的选择是广泛的,其中一个获得巨大欢迎的平台是Bagisto。这种开源电子商务解决方案提供灵活性、可扩展性和广泛的功能集,使其成为企业家和企业的理想选择。
在AlmaLinux 9上安装Bagisto
第 1 步。在开始安装过程之前,请确保您的 AlmaLinux 9 系统是最新的。在终端中运行以下命令:
<span class="pln">sudo dnf clean all sudo dnf update</span>
第 2 步。设置灯堆栈。
Bagisto依赖于LAMP堆栈(Linux,Apache,MySQL,PHP)。让我们安装和配置这些组件。
安装 Apache Web 服务器:
<span class="pln">sudo dnf install httpd</span>
启动并使 Apache 能够在启动时运行:
<span class="pln">systemctl start httpd systemctl enable httpd</span>
安装 MySQL 数据库服务器:
<span class="pln">sudo dnf install mariadb</span><span class="pun">-</span><span class="pln">server mariadb</span>
启动并启用 MySQL:
<span class="pln">systemctl start mariadb systemctl enable mariadb</span>
Bagisto 需要 PHP 7.4 或更高版本。安装 PHP 和必要的模块:
<span class="pln">sudo dnf install php php</span><span class="pun">-</span><span class="pln">mysqlnd php</span><span class="pun">-</span><span class="pln">json php</span><span class="pun">-</span><span class="pln">zip php</span><span class="pun">-</span><span class="pln">gd php</span><span class="pun">-</span><span class="pln">mbstring php</span><span class="pun">-</span><span class="pln">curl php</span><span class="pun">-</span><span class="pln">xml php</span><span class="pun">-</span><span class="pln">bcmath php</span><span class="pun">-</span><span class="pln">json</span>
要增强 Bagisto 的功能,请安装其他 PHP 扩展:
<span class="pln">sudo dnf install php</span><span class="pun">-</span><span class="pln">zip php</span><span class="pun">-</span><span class="pln">dom php</span><span class="pun">-</span><span class="pln">simplexml php</span><span class="pun">-</span><span class="pln">xml php</span><span class="pun">-</span><span class="pln">xmlreader php</span><span class="pun">-</span><span class="pln">xmlwriter</span>
第 3 步。在AlmaLinux 9上安装Bagisto。
导航到网络根目录并下载Bagisto。最新版本的URL可以在官方的Bagisto GitHub存储库中找到:
<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html wget https</span><span class="pun">:</span><span class="com">//github.com/bagisto/bagisto/archive/refs/tags/v1.5.1.zip</span><span class="pln"> unzip v1</span><span class="pun">.</span><span class="lit">5.1</span><span class="pun">.</span><span class="pln">zip mv bagisto</span><span class="pun">-</span><span class="lit">1.5</span><span class="pun">.</span><span class="lit">1</span><span class="pln"> bagisto</span>
接下来,在 Bagisto 目录中创建一个文件并配置数据库设置。将 、 和替换为数据库信息:.env
your_database
your_username
your_password
<span class="pln">cd </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">bagisto cp </span><span class="pun">.</span><span class="pln">env</span><span class="pun">.</span><span class="pln">example </span><span class="pun">.</span><span class="pln">env nano </span><span class="pun">.</span><span class="pln">env</span>
更新以下变量:
<span class="pln">APP_URL</span><span class="pun">=</span><span class="pln">http</span><span class="pun">:</span><span class="com">//yourdomain.com</span><span class="pln"> DB_CONNECTION</span><span class="pun">=</span><span class="pln">mysql DB_HOST</span><span class="pun">=</span><span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pln"> DB_PORT</span><span class="pun">=</span><span class="lit">3306</span><span class="pln"> DB_DATABASE</span><span class="pun">=</span><span class="pln">bagistodb DB_USERNAME</span><span class="pun">=</span><span class="pln">bagistouser DB_PASSWORD</span><span class="pun">=</span><span class="pln">your</span><span class="pun">-</span><span class="pln">strong</span><span class="pun">-</span><span class="pln">passwd</span>
要确保 Web 服务器可以访问和修改 Bagisto 文件,请设置正确的权限和所有权:
<span class="pln">chown </span><span class="pun">-</span><span class="pln">R apache</span><span class="pun">:</span><span class="pln">apache </span><span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">bagisto chmod </span><span class="pun">-</span><span class="pln">R </span><span class="lit">755</span> <span class="pun">/</span><span class="kwd">var</span><span class="pun">/</span><span class="pln">www</span><span class="pun">/</span><span class="pln">html</span><span class="pun">/</span><span class="pln">bagisto</span>
第 4 步。为 Bagisto 创建一个数据库。
访问MySQL命令行界面并为Bagisto创建一个数据库:
<span class="pln">mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>
这将提示您输入密码,因此请输入您的MariaDB root密码并按Enter键。登录到数据库服务器后,您需要为Bagisto安装创建一个数据库:
<span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE DATABASE bagistodb</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE USER </span><span class="str">'bagistouser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your-strong-passwd'</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> GRANT ALL ON bagistodb</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'bagistouser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> WITH GRANT OPTION</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> FLUSH PRIVILEGES</span><span class="pun">;</span> <span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> EXIT</span><span class="pun">;</span>
第5步。配置巴吉斯托。
现在,通过生成密钥、设定数据库种子和执行迁移来配置 Bagisto:
<span class="pln">php artisan key</span><span class="pun">:</span><span class="pln">generate php artisan migrate php artisan db</span><span class="pun">:</span><span class="pln">seed</span>
迁移数据库表并使用必要的数据为其设定种子:
<span class="pln">php artisan migrate </span><span class="pun">--</span><span class="pln">seed</span>
生成唯一的应用程序密钥:
<span class="pln">php artisan key</span><span class="pun">:</span><span class="pln">generate</span>
第 6 步。设置 SSL 以实现安全访问。
为了使用SSL保护您的Bagisto安装,我们将使用Let’s Encrypt和Certbot。首先,安装 Certbot:
<span class="pln">sudo dnf install certbot python3</span><span class="pun">-</span><span class="pln">certbot</span><span class="pun">-</span><span class="pln">apache</span>
使用Certbot为您的域获取免费的SSL证书。替换为您的实际域:yourdomain.com
<span class="pln">certbot </span><span class="pun">--</span><span class="pln">apache </span><span class="pun">-</span><span class="pln">d yourdomain</span><span class="pun">.</span><span class="pln">com</span>
按照屏幕上的提示配置 SSL 证书。Certbot 将自动配置 Apache 以使用 SSL。
为确保您的 SSL 证书保持有效,请设置自动续订:
<span class="pln">certbot renew </span><span class="pun">--</span><span class="pln">dry</span><span class="pun">-</span><span class="pln">run</span>
步骤 7.配置防火墙。
您的防火墙必须允许 Apache 端口 80 (HTTP) 和 443 (HTTPS) 上的传入流量。相应地更新防火墙规则:
<span class="pln">firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">service</span><span class="pun">=</span><span class="pln">http firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">permanent </span><span class="pun">--</span><span class="kwd">add</span><span class="pun">-</span><span class="pln">service</span><span class="pun">=</span><span class="pln">https firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">reload</span>
第8步。通过网络浏览器访问巴吉斯托。
打开您的网络浏览器并导航到您的域,例如 .您应该会看到巴吉斯托设置向导。https://yourdomain.com
感谢您使用本教程在您的 AlmaLinux 9 系统上安装 Bagisto 电子商务平台。如需其他帮助或有用信息,我们建议您查看 Bagisto 官方网站。