如何在 Ubuntu 22.04 上安装 TYPO3 CMS

如何在 Ubuntu 22.04 上安装 TYPO3 CMS

TYPO3 是一个免费、开源的企业级内容管理系统。 它是用 PHP 编写的,结合了开源代码、可靠性和可扩展性。 它是跨平台的,可以安装在所有主流操作系统上,包括Windows、Linux、macOS等。它是为初学者用户设计的,因此您无需编写代码即可轻松定制和扩展它。 它简单、响应灵敏、适合移动设备,是快速启动和运行网站的绝佳选择。

本教程将向您展示如何在 Ubuntu 22.04 上使用 Let’s Encrypt SSL 安装 TYPO3 CMS。

先决条件

  • 运行 Ubuntu 22.04 的服务器。
  • 有效的域名已链接到您的服务器 IP。
  • 服务器上配置了 root 密码。

入门

首先,建议将系统软件包更新为最新版本。 您可以通过运行以下命令来更新所有包:

apt update -y
apt upgrade -y

所有软件包都是最新的后,您可以继续下一步。

安装 Apache、PHP 和 MariaDB 服务器

接下来,您需要在服务器上安装 Apache Web 服务器、MariaDB、PHP 和其他 PHP 扩展。 您可以使用以下命令安装所有这些:

apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-gmp php-curl php-intl php-mbstring php-xmlrpc php-mysql php-gd php-xml php-cli php-zip curl git gnupg2 -y

安装所有软件包后,编辑 php.ini 文件并更改一些推荐设置:

nano /etc/php/8.1/apache2/php.ini

更改以下行:

memory_limit = 256M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 360
max_input_vars = 1500
date.timezone = UTC

保存并关闭文件,然后重新启动 Apache 服务以应用更改:

systemctl restart apache2

为 TYPO3 创建数据库

接下来,您需要为 TYPO3 创建数据库和用户。 首先,使用以下命令登录 MariaDB shell:

mysql

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

MariaDB [(none)]> CREATE DATABASE typo3db;

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

MariaDB [(none)]> GRANT ALL ON typo3db.* TO 'typo3user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

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

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

至此,您的 MariaDB 数据库已配置完毕。 您现在可以继续下一步。

安装TYPO3 CMS

首先,访问TYPO3官网,使用curl命令下载最新版本的TYPO3:

curl -L -o typo3_src.tgz https://get.typo3.org/11

下载完成后,使用以下命令解压下载的文件:

tar -xvzf typo3_src.tgz

接下来,将解压的目录移动到 Apache Web 根目录:

mv typo3_src-11.5.15 /var/www/html/typo3

接下来,使用以下命令授予适当的权限和权限:

chown -R www-data:www-data /var/www/html/typo3
chmod -R 775 /var/www/html/typo3

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

为 TYPO3 创建 Apache 虚拟主机

接下来,创建 Apache 虚拟主机配置文件来托管 TYPO3 CMS。 您可以使用以下命令创建它:

nano /etc/apache2/sites-available/typo3.conf

添加以下行:


     ServerAdmin [email protected]
     DocumentRoot /var/www/html/typo3
     ServerName typo3.example.com
     
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined


保存并关闭文件,然后使用以下命令启用虚拟主机配置文件和重写模块:

a2ensite typo3.conf
a2enmod rewrite

接下来,重新启动 Apache 服务以应用更改:

systemctl restart apache2

此时,Apache Web 服务器已配置为服务 TYPO3。 您现在可以继续下一步。

访问TYPO3 CMS

如果您在新服务器中安装 TYPO3,则需要在 TYPO3 Web 根目录中创建一个 FIRST_INSTALL 文件。 您可以使用以下命令创建它:

touch /var/www/html/typo3/FIRST_INSTALL
chown -R www-data:www-data /var/www/html/typo3/FIRST_INSTALL

现在,打开 Web 浏览器并使用 URL http://typo3.example.com 访问 TYPO3。 您应该看到以下页面:

提供您的数据库用户名、密码、主机,然后单击“继续”按钮。 您应该看到以下页面:

选择您的 TYPO3 数据库名称,然后单击“继续”按钮。 您应该看到以下页面:

接下来,提供您的管理员用户名、密码、站点名称,然后单击“继续”按钮。 您将被重定向到 TYPO3 登录页面:

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

使用 Let’s Encrypt 保护 TYPO3

使用 Let’s Encrypt Free SSL 保护您的网站是一个好主意。 首先,安装 Certbot 客户端来安装和管理 SSL。 您可以使用以下命令安装它:

apt-get install python3-certbot-apache -y

安装后,运行以下命令以使用 Let’s Encrypt SSL 保护您的网站:

certbot --apache -d typo3.example.com

您将被要求提供您的电子邮件并接受服务条款,如下所示:

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing 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
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for typo3.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/typo3-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/typo3-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/typo3-le-ssl.conf

接下来,选择是否将 HTTP 流量重定向到 HTTPS,如下所示:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

输入 2 并按 Enter 为您的网站安装 Let’s Encrypt SSL:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/typo3.conf to ssl vhost in /etc/apache2/sites-available/typo3-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://typo3.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=typo3.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/typo3.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/typo3.example.com/privkey.pem
   Your cert will expire on 2022-12-07. 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 https://typo3.example.com 安全地访问 TYPO3 CMS。

结论

恭喜 您已在 Ubuntu 22.04 上成功安装 TYPO3 CMS 并使用 Let’s Encrypt SSL 对其进行保护。 您现在可以通过网络浏览器轻松创建网站和博客。 如果您有任何疑问,请随时问我。

资讯来源:由0x资讯编译自HOWTOFORGE,版权归作者所有,未经许可,不得转载
你可能还喜欢