如何使用 Apache 安装 PrestaShop 并在 CentOS 8 上加密 SSL如何使用 Apache 安装 PrestaShop 并在 CentOS 8 上加密 SSL如何使用 Apache 安装 PrestaShop 并在 CentOS 8 上加密 SSL如何使用 Apache 安装 PrestaShop 并在 CentOS 8 上加密 SSL
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

如何使用 Apache 安装 PrestaShop 并在 CentOS 8 上加密 SSL

发表 admin at 2025年2月28日
类别
  • 未分类
标签

在此页

  1. 先决条件
  2. 安装 LAMP 服务器
  3. 为 PrestaShop 创建数据库
  4. 安装 PrestaShop
  5. 为 PrestaShop 配置 Apache
  6. 配置防火墙
  7. 访问 PrestaShop
  8. 使用 Lets Encrypt SSL 保护 PrestaShop
  9. 结论

PrestaShop 是一个用 PHP 编写的开源购物车,用于创建和管理您的在线业务。它提供了一个简单易用的界面,可帮助您在最短的时间内启动在线商店。它提供了许多功能,包括用户友好的界面、多个支付网关(PayPal、Google Checkout)、移动响应设计、免费支持、多语言、分析、报告等。

在本文中,我们将向您展示如何在 CentOS 8 上使用 Apache 和免费的 Lets Encrypt SSL 证书安装 PrestaShop。

先决条件

  • 一台运行 CentOS 8 的服务器。
  • 用您的服务器 IP 指向的有效域名。
  • 在您的服务器上配置了根密码。

安装 LAMP 服务器

在开始之前,必须在您的服务器中安装 LAMP 服务器。如果未安装,您可以使用以下命令将其与其他 PHP 扩展一起安装:

dnf install httpd mariadb-server php php-cli php-bcmath php-mysqli php-gd php-pdo php-xmlrpc php-intl php-posix php-json php-curl php-zip unzip -y

安装所有必需的包后,编辑 php.ini 文件并更改一些默认设置:

nano /etc/php.ini

更改以下行:

max_input_vars = 3000
post_max_size = 64M
upload_max_filesize = 64M
max_execution_time = 600
memory_limit = 256M
date.timezone = Asia/Kolkata

保存并关闭文件,然后启动 Apache 和 MariaDB 服务并使它们能够在系统重启时启动:

systemctl start httpd
systemctl start mariadb
systemctl enable httpd
systemctl enable mariadb

此时,LAMP 服务器已安装到您的服务器中。

为 PrestaShop 创建数据库

PrestaShop 使用 MySQL/MariaDB 数据库来存储他们的数据。因此,您需要为 PrestaShop 创建数据库和用户。

首先,使用以下命令登录 MariaDB:

mysql

登录后,使用以下命令创建数据库和用户:

MariaDB [(none)]> CREATE DATABASE prestashopdb;
MariaDB [(none)]> CREATE USER 'prestashopuser'@'localhost' IDENTIFIED BY 'securepassword';

接下来,使用以下命令授予 prestashopdb 的所有权限:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashopdb. * TO 'prestashopuser'@'localhost';

接下来,使用以下命令刷新权限并退出 MariaDB:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

完成后,您可以继续下一步。

安装 PrestaShop

接下来,您需要从其官方下载页面下载最新版本的 PrestaShop。您可以使用以下命令下载它:

wget https://download.prestashop.com/download/releases/prestashop_1.7.7.3.zip

下载完成后,使用以下命令将下载的文件解压缩到 Apache Web 根目录:

unzip prestashop_1.7.7.3.zip -d /var/www/html/prestashop

接下来,使用以下命令为 prestashop 目录设置正确的所有权:

chown -R apache:apache /var/www/html/prestashop

完成后,您可以继续下一步。

为 PrestaShop 配置 Apache

接下来,您需要为 PrestaShop 创建一个 Apache 虚拟主机配置文件。您可以使用以下命令创建它:

nano /etc/httpd/conf.d/prestashop.conf

添加以下行:

<VirtualHost *:80>
    ServerAdmin 
    ServerName prestashop.example.com
    DocumentRoot /var/www/html/prestashop

    <Directory /var/www/html/prestashop>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/prestashop-error_log
    CustomLog /var/log/httpd/prestashop-access_log common
</VirtualHost>

完成后保存并关闭文件。接下来,重新启动 Apache 服务以应用更改:

systemctl restart httpd

接下来,使用以下命令验证 Apache 服务的状态:

systemctl status httpd

您应该得到以下输出:

? httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           ??php-fpm.conf
   Active: active (running) since Wed 2021-04-07 01:04:19 EDT; 2h 2min ago
     Docs: man:httpd.service(8)
 Main PID: 47841 (httpd)
   Status: "Total requests: 313; Idle/Busy workers 100/0;Requests/sec: 0.0425; Bytes served/sec: 1.2KB/sec"
    Tasks: 278 (limit: 12524)
   Memory: 35.9M
   CGroup: /system.slice/httpd.service
           ??47841 /usr/sbin/httpd -DFOREGROUND
           ??47843 /usr/sbin/httpd -DFOREGROUND
           ??47844 /usr/sbin/httpd -DFOREGROUND
           ??47845 /usr/sbin/httpd -DFOREGROUND
           ??47846 /usr/sbin/httpd -DFOREGROUND
           ??48061 /usr/sbin/httpd -DFOREGROUND

Apr 07 01:04:19 centos8 systemd[1]: Stopped The Apache HTTP Server.
Apr 07 01:04:19 centos8 systemd[1]: Starting The Apache HTTP Server...

完成后,您可以继续下一步。

配置防火墙

接下来,您需要允许端口 80 和 443 通过防火墙。您可以使用以下命令允许它们:

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https

接下来,重新加载防火墙以应用更改:

firewall-cmd --reload

完成后,您可以继续下一步。

访问 PrestaShop

现在,打开您的 Web 浏览器并使用 URL http://prestashop.example.com 访问 PrestaShop Web 界面。您将被重定向到以下页面:

选择您的语言,然后单击“下一步”按钮。您应该会看到以下页面:

同意许可协议并单击下一步按钮。您应该会看到以下页面:

提供您的商店名称、国家信息、帐户信息,然后单击“下一步”按钮。您应该会看到以下页面:

提供您的数据库名称、数据库用户名、密码,然后单击“下一步”按钮。安装完成后,您应该会看到以下页面:

单击“管理您的商店”按钮。您应该会看到以下页面:

现在,使用以下命令删除安装文件夹:

rm -rf /var/www/html/prestashop/install

接下来,单击 PrestaShop 管理 URL。您应该会看到以下页面:

提供您的管理员用户名和密码,然后单击“登录”按钮。您应该在以下页面中看到 PrestaShop 仪表板:

使用 Lets Encrypt SSL 保护 PrestaShop

接下来,您需要安装 Certbot 客户端来为 PrestaShop 安装 Lets Encrypt SSL。您可以使用以下命令安装它:

dnf install letsencrypt python3-certbot-apache

接下来,使用以下命令为您的 lets 域获取并安装 SSL 证书:

certbot --apache -d prestashop.example.com

您将被要求提供您的电子邮件地址并接受服务条款:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Account registered.
Requesting a certificate for prestashop.example.com
Performing the following challenges:
http-01 challenge for prestashop.example.com
Waiting for verification.
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/httpd/conf.d/prestashop.conf
Redirecting all traffic on port 80 to ssl in /etc/httpd/conf.d/prestashop.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://prestashop.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subscribe to the EFF mailing list (email: ).


IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/prestashop.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/prestashop.example.com/privkey.pem
   Your certificate will expire on 2021-06-09. To obtain a new or
   tweaked version of this certificate in the future, simply run
   certbot again with the "certonly" option. To non-interactively
   renew *all* of your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

您现在可以使用按设备重定向的 URL 安全地访问您的网站,请查看此处。

结论

恭喜!您已经在 CentOS 8 上成功安装了带有 Apache 和 Lets Encrypt SSL 的 PrestaShop。您现在可以将您的产品添加到 PrestaShop 并开始在线销售。如果您有任何问题,请随时问我。

©2015-2025 Norria support@norria.com