如何在AlmaLinux 9上安装PrestaShop。

Linux命令 Edge插件网 1年前 (2023-10-27) 299次浏览 已收录 0个评论

在当今的数字时代,电子商务正在蓬勃发展,拥有稳固的在线形象是必要的。PrestaShop是一个开源电子商务平台,为各种规模的企业提供了强大的解决方案。通过将PrestaShop与AlmaLinux 9上的LAMP(Linux,Apache,MariaDB,PHP)堆栈相结合,您可以创建一个安全高效的在线商店。

如何在AlmaLinux 9上安装PrestaShop。

在AlmaLinux 9上安装PrestaShop

第 1 步。首先更新您的 AlmaLinux 9 服务器,以确保您拥有最新的软件包和安全更新:

<span class="pln">sudo dnf clean all
sudo dnf update</span>

此命令将更新您的软件包存储库,确保您拥有最新的软件包和安全补丁。

第 2 步。在AlmaLinux上安装LAMP堆栈。

在我们深入研究本教程之前,确保您的服务器配备强大的 LAMP 堆栈至关重要。如果您尚未设置 LAMP,请不要担心 – 我们已经为您提供了保障。只需按照我们在此处提供的综合指南进行操作即可。

第 3 步。在AlmaLinux 9安装PrestaShop

安装PrestaShop,您需要从其官方网站检索最新版本。使用以下命令下载最新的PrestaShop存档:wget

<span class="pln">wget https</span><span class="pun">:</span><span class="com">//github.com/PrestaShop/PrestaShop/releases/download/8.1.2/prestashop_8.1.2.zip</span>

将下载的文件解压缩到 Apache 文档根目录:

<span class="pln">sudo unzip prestashop_8</span><span class="pun">.</span><span class="lit">1.2</span><span class="pun">.</span><span class="pln">zip </span><span class="pun">-</span><span class="pln">d </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>

调整 PrestaShop 的文件权限以确保 Web 服务器可以访问这些文件:

<span class="pln">sudo 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">prestashop
sudo 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">prestashop</span>

第 4 步。配置 MariaDB。

默认情况下,MariaDB 未强化。您可以使用脚本保护 MariaDB。您应该仔细阅读每个步骤,这将设置一个 root 密码,删除匿名用户,禁止远程 root 登录,并删除测试数据库和对安全 MariaDB 的访问权限:mysql_secure_installation

<span class="pln">mysql_secure_installation</span>

使用 MariaDB 命令行工具为 PrestaShop 创建数据库:

<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键。登录到数据库服务器后,您需要为PrestaShop安装创建一个数据库:

<span class="typ">MariaDB</span> <span class="pun">[(</span><span class="pln">none</span><span class="pun">)]></span><span class="pln"> CREATE DATABASE presta_db</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">'presta_user'</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 presta_db</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'presta_user'</span><span class="pun">@</span><span class="str">'localhost'</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步。为 PrestaShop 创建虚拟主机。

要为 PrestaShop 创建虚拟主机,您需要编辑 Apache 虚拟主机配置文件。使用文本编辑器打开配置文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">httpd</span><span class="pun">/</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">prestashop</span><span class="pun">.</span><span class="pln">conf</span>

添加以下虚拟主机配置,并替换为您的实际域名:yourdomain.com

<span class="tag"><VirtualHost</span><span class="pln"> *:80</span><span class="tag">></span><span class="pln">
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/html/prestashop
ServerName yourdomain.com
ServerAlias www.yourdomain.com
</span><span class="tag"></VirtualHost></span>

保存更改并退出文本编辑器。启用虚拟主机配置并重新启动 Apache :

<span class="pln">sudo a2ensite prestashop</span><span class="pun">.</span><span class="pln">conf
sudo systemctl restart httpd</span>

第 6 步。安全预购。

现在,让我们使用 Certbot 设置 HTTPS。如果您尚未安装 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 mod_ssl
sudo certbot </span><span class="pun">--</span><span class="pln">apache</span>

让我们加密SSL证书的有效期为90天。为了确保对PrestaShop商店的HTTPS访问不间断,您应该设置自动证书续订。

Certbot 可以将 cron 作业配置为在证书即将到期时自动续订证书。运行以下命令以启用自动续订:

<span class="pln">sudo certbot renew </span><span class="pun">--</span><span class="pln">dry</span><span class="pun">-</span><span class="pln">run</span>

步骤 7.配置防火墙。

在开始为 PrestaShop 配置防火墙之前,必须了解 firewalld 服务的当前状态:

<span class="pln">sudo systemctl status firewalld</span>

要为 PrestaShop 所需的服务打开端口,请使用 or 命令。例如,如果 PrestaShop 使用 HTTP(端口 80)和 HTTPS(端口 443):--add-service--add-port

<span class="pln">sudo 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
sudo 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</span>

要查看活动规则的列表,请运行:

<span class="pln">sudo firewall</span><span class="pun">-</span><span class="pln">cmd </span><span class="pun">--</span><span class="pln">list</span><span class="pun">-</span><span class="pln">all</span>

第8步。访问PrestaShop Web UI。

要确保您的PrestaShop商店正常运行,请打开您的网络浏览器并导航到您的域(例如,)。您应该看到您的PrestaShop商店的前端。https://yourdomain.com

如何在AlmaLinux 9上安装PrestaShop。

感谢您使用本教程在AlmaLinux 9系统上安装PrestaShop。有关其他帮助或有用信息,我们建议您查看PrestaShop官方网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在AlmaLinux 9上安装PrestaShop。
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址