如何在 Debian 11 上安装 PrestaShop

在本教程中,我们将向您展示如何在 Debian 11 上安装 PrestaShop。对于那些不知道的人,PrestaShop 是一个免费增值的开源电子商务软件。 它让您可以通过安全支付、多种运输方式、自定义主题等方式创建自己的在线商店。 用 PHP 编写的 PrestaShop 具有高度可定制性,支持所有主要的支付服务,被翻译成多种语言并针对许多国家进行本地化,具有完全响应式设计(前台和后台)等。

本文假设您至少具备 Linux 的基本知识,知道如何使用 shell,最重要的是,您将网站托管在自己的 VPS 上。 安装非常简单,假设您在 root 帐户下运行,如果不是,您可能需要添加 ‘sudo‘ 到命令以获取 root 权限。 我将向您展示如何在 Debian 11 (Bullseye) 上逐步安装 PrestaShop 电子商务软件。

在 Debian 11 Bullseye 上安装 PrestaShop

第 1 步。在我们安装任何软件之前,重要的是通过运行以下命令确保您的系统是最新的 apt 终端中的命令:

sudo apt update sudo apt upgrade

步骤 2. 安装 LAMP 堆栈。

需要 Debian 11 LAMP 服务器。 如果您没有安装 LAMP,请阅读我们之前的教程以在 Debian 11 上安装 LAMP 服务器。

步骤 3. 在 Debian 11 上安装 PrestaShop。

默认情况下,PrestaShop 在 Debian 11 基础存储库中不可用。 所以,现在我们从官方页面下载最新的稳定版 PrestaShop:

wget https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.1/prestashop_1.7.8.1.zip

接下来,解压下载的文件:

unzip prestashop_1.7.8.1.zip sudo mv * /var/www/html/www.your-domain.com/

我们将需要更改一些文件夹权限:

sudo chown -R www-data:www-data /var/www/html/www.your-domian.com/

步骤 4. 配置 MariaDB。

默认情况下,MariaDB 未加固。 您可以使用 mysql_secure_installation 脚本。 您应该仔细阅读下面的每个步骤,这些步骤将设置 root 密码、删除匿名用户、禁止远程 root 登录,以及删除测试数据库和访问安全 MariaDB:

mysql_secure_installation

像这样配置它:

- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y

接下来,我们需要登录 MariaDB 控制台并为 PrestaShop 创建一个数据库。 运行以下命令:

mysql -u root -p

这将提示您输入密码,因此输入您的 MariaDB 根密码并点击 Enter. 登录到数据库服务器后,您需要为 PrestaShop 安装创建一个数据库:

MariaDB [(none)]> CREATE DATABASE prestashop_db; MariaDB [(none)]> CREATE USER 'prestashop_user'@'localhost' IDENTIFIED BY 'your-strong-password'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop_db.* to [email protected]'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit

步骤 5. 配置 Apache.

现在我们创建一个新的 VirtualHost 来更好地管理 PrestaShop 网站:

sudo nano /etc/apache2/sites-available/www.your-domain.com.conf

添加以下文件:

<VirtualHost *:80>     ServerName your-domain.com    ServerAlias www.your-domain.com    ServerAdmin [email protected]    DocumentRoot /var/www/html/www.your-domain.com     ErrorLog ${APACHE_LOG_DIR}/www.your-domain.com_error.log    CustomLog ${APACHE_LOG_DIR}/www.your-domain.com_access.log combined     <Directory /var/www/html/www.your-domain.com>       Options FollowSymlinks       AllowOverride All       Require all granted    </Directory>  </VirtualHost>

Save 和 close,然后重新启动 Apache 网络服务器,以便进行更改:

sudo a2ensite www.your-domian.com sudo a2enmod rewrite ssl sudo systemctl restart apache2

步骤 6. 安装 Let’s Encrypt 证书。

首先,使用以下命令将 Certbot 安装到您的 Debian 系统:

sudo apt install certbot python3-certbot-apache

然后,使用以下命令生成证书:

sudo certbot --apache -d [your-domain.com]

然后将提示您输入证书的电子邮件地址。 输入后,您必须同意 T&C 并决定是否要与电子前沿基金会共享您的电子邮件地址。 最后一步是可选的。 成功后重新加载 Apache 再次加载所有新配置。

步骤 7。访问 PrestaShop Web 界面。

成功安装后,打开您的网络浏览器并使用 URL 访问 PrestaShop https://your-domian.com. 您将被重定向到 PrestaShop 界面页面:

恭喜! 您已成功安装 PrestaShop。 感谢您使用本教程在 Debian 11 Bullseye 上安装最新版本的 PrestaShop 电子商务内容管理平台。 如需更多帮助或有用信息,我们建议您查看 PrestaShop 官方网站.