如何在 Debian 12 上安装 PrestaShop

Linux命令 Edge插件网 8个月前 (11-10) 219次浏览 已收录 0个评论

PrestaShop 是一个功能强大的开源电子商务平台,可让您轻松创建和管理您的在线商店。如果您是 Debian 12 用户,并且想使用命令行界面 (CLI) 设置 PrestaShop,那么您来对地方了。

如何在 Debian 12 上安装 PrestaShop

在 Debian 上安装 PrestaShop 12 Bookworm

步骤 1。为了保证顺利安装,更新和升级您的 Debian 系统至关重要。使用以下命令使系统保持最新状态:

<span class="pln">sudo apt update
sudo apt upgrade</span>

此命令更新软件包列表,并将已安装的软件包升级到最新版本。

第2步。安装 LEMP 堆栈。

安装 PrestaShop 之前,您需要在 Debian 服务器上设置一个 LAMP(Linux、Nginx、MariaDB、PHP)堆栈。

第 3 步。配置 PHP。

编辑PHP配置文件以针对PrestaShop进行优化。打开 PHP-FPM 配置文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">php</span><span class="pun">/</span><span class="lit">7.x</span><span class="pun">/</span><span class="pln">fpm</span><span class="pun">/</span><span class="pln">php</span><span class="pun">.</span><span class="pln">ini</span>

查找并修改以下行:

<span class="pln">memory_limit </span><span class="pun">=</span> <span class="lit">256M</span><span class="pln">
max_execution_time </span><span class="pun">=</span> <span class="lit">300</span><span class="pln">
upload_max_filesize </span><span class="pun">=</span> <span class="lit">16M</span><span class="pln">
post_max_size </span><span class="pun">=</span> <span class="lit">16M</span>

保存并退出编辑器,然后重新启动 PHP-FPM 以使更改生效:

<span class="pln">sudo systemctl restart php7</span><span class="pun">.</span><span class="pln">x</span><span class="pun">-</span><span class="pln">fpm</span>

第 4 步。配置 MariaDB。

为 PrestaShop 创建数据库和用户:

<span class="pln">sudo mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>

在 MariaDB shell 中,运行以下命令,将 、 替换为首选数据库名称、用户和密码:yourdbyouruseryour_strong_password

<span class="pln">CREATE DATABASE yourdb</span><span class="pun">;</span><span class="pln">
CREATE USER </span><span class="str">'youruser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your_strong_password'</span><span class="pun">;</span><span class="pln">
GRANT ALL PRIVILEGES ON yourdb</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'youruser'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pun">;</span><span class="pln">
FLUSH PRIVILEGES</span><span class="pun">;</span><span class="pln">
EXIT</span><span class="pun">;</span>

第 5 步。在 Debian 12安装 PrestaShop

首先,在Web根目录中为PrestaShop创建一个目录。我们将使用:/var/www/html

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

将PrestaShop存储库从GitHub克隆到指定目录:

<span class="pln">sudo git clone https</span><span class="pun">:</span><span class="com">//github.com/PrestaShop/PrestaShop.git .</span>

若要确保使用最新的稳定版本,请更新存储库:

<span class="pln">sudo git checkout develop
sudo git pull</span>

第 6 步。配置 Nginx。

创建一个新的 Nginx 服务器块配置文件:

<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">prestashop</span>

粘贴以下配置:

<span class="pln">server </span><span class="pun">{</span><span class="pln">
    listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln">
    server_name your_domain</span><span class="pun">.</span><span class="pln">com</span><span class="pun">;</span><span class="pln">
    root </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><span class="pun">;</span><span class="pln">
    index index</span><span class="pun">.</span><span class="pln">php</span><span class="pun">;</span><span class="pln">

    location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln">
        try_files $uri $uri</span><span class="pun">/</span> <span class="pun">/</span><span class="pln">index</span><span class="pun">.</span><span class="pln">php$is_args$args</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~</span><span class="pln"> \.php$ </span><span class="pun">{</span><span class="pln">
        include snippets</span><span class="pun">/</span><span class="pln">fastcgi</span><span class="pun">-</span><span class="pln">php</span><span class="pun">.</span><span class="pln">conf</span><span class="pun">;</span><span class="pln">
        fastcgi_pass unix</span><span class="pun">:</span><span class="str">/run/</span><span class="pln">php</span><span class="pun">/</span><span class="pln">php7</span><span class="pun">.</span><span class="pln">x</span><span class="pun">-</span><span class="pln">fpm</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">;</span>
    <span class="pun">}</span><span class="pln">

    location </span><span class="pun">~</span> <span class="pun">/</span><span class="pln">\.ht </span><span class="pun">{</span><span class="pln">
        deny all</span><span class="pun">;</span>
    <span class="pun">}</span>
<span class="pun">}</span>

保存并退出文件,然后启用配置并重新启动 Nginx:

<span class="pln">sudo ln </span><span class="pun">-</span><span class="pln">s </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">prestashop </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">enabled</span><span class="pun">/</span><span class="pln">
sudo nginx </span><span class="pun">-</span><span class="pln">t
sudo systemctl restart nginx</span>

确保 Web 服务器用户 (www-data) 具有适当的权限:

<span class="pln">sudo chown </span><span class="pun">-</span><span class="pln">R www</span><span class="pun">-</span><span class="pln">data</span><span class="pun">:</span><span class="pln">www</span><span class="pun">-</span><span class="pln">data </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>

第 7 步。配置 SSL。

要使用 Certbot 和 Nginx 在 Debian 12 上的 PrestaShop 中为安全连接配置 SSL,请按照下列步骤操作:

<span class="pln">sudo apt update
sudo apt install certbot python3</span><span class="pun">-</span><span class="pln">certbot</span><span class="pun">-</span><span class="pln">nginx</span>

现在,使用 Certbot 为您的 PrestaShop 商店获取并安装 SSL 证书:

<span class="pln">sudo certbot </span><span class="pun">--</span><span class="pln">nginx</span>

Certbot 将提示您选择要为其获取证书的域。选择您的 PrestaShop 域,然后按照提示完成证书安装。

Certbot 提供 SSL 证书的自动续订,确保您的 PrestaShop 商店保持安全。续订过程通常由 systemd 计时器处理,该计时器每天运行两次。您可以通过运行以下命令手动测试证书续订过程:

<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>

第 8 步。配置防火墙。

配置防火墙以保护您的PrestaShop服务器。UFW(Uncomplicated Firewall)是一个用户友好的工具,用于此目的:

<span class="pln">sudo apt install ufw
sudo ufw allow </span><span class="typ">OpenSSH</span><span class="pln">
sudo ufw allow </span><span class="str">'Nginx Full'</span><span class="pln">
sudo ufw enable</span>

第 9 步。访问 PrestaShop Web UI。

要访问PrestaShop管理面板,请转到您的后台URL(例如,)。使用您在安装过程中创建的管理员凭据登录:https://your-domain_or_your-IP-address

如何在 Debian 12 上安装 PrestaShop

感谢您使用本教程在 Debian 12 Bookworm 上安装最新版本的 PrestaShop 电子商务平台。如需更多帮助或有用信息,我们建议您查看 PrestaShop 官方网站


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

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

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