如何在 Ubuntu 22.04 上安装 Neos CMS
本教程适用于这些操作系统版本
- Ubuntu 22.04(果酱水母)
- Ubuntu 18.04(仿生海狸)
在此页
- 先决条件
- 开始
- 安装 Apache、MariaDB 和 PHP
- 为 Neos CMS 创建数据库
- 安装 Neos CMS
- 为 Neos CMS 配置 Apache
- 访问 Neos CMS
- 使用 Lets Encrypt 保护 Neos CMS
- 结论
Neos CMS 是一个免费、开源和创新的内容管理系统,可帮助您在没有任何编码知识的情况下管理网站和博客。它简单、安全且易于使用,可帮助企业所有者跨多种设备与用户协作。它提供了非常有用的功能,包括完整的 Unicode 支持、完整的国际化、SEO、内联编辑等等。该项目背后的核心理念是允许编辑人员尽可能无缝地编辑内容,同时仍保留其结构。
在本教程中,我们将向您展示如何在 Ubuntu 22.04 服务器上使用 Apache 和 Lets Encrypt SSL 安装 Neos CMS。
先决条件
- 一台运行 Ubuntu 22.04 的服务器。
- 使用您的服务器 IP 指向一个有效的域名。
- 在服务器上配置了根密码。
入门
首先,运行以下命令将所有系统包更新到更新版本:
apt update -y
apt upgrade -y
完成后,您可以继续下一步。
安装 Apache、MariaDB 和 PHP
接下来,您需要将 Apache、MariaDB、PHP 和其他所需的软件包安装到您的系统中。运行以下命令来安装所有这些:
apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-mysql php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-bcmath php-xml php-cli php-gmagick php-zip curl unzip git -y
安装所有包后,编辑 php.ini 文件并进行一些更改:
nano /etc/php/8.1/apache2/php.ini
更改以下行:
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 150M
max_execution_time = 360
date.timezone = UTC
保存并关闭文件,然后重新启动 Apache 服务以应用更改:
systemctl restart apache2
为 Neos CMS 创建数据库
首先,您需要设置 MariaDB root 密码并确保安装安全。您可以使用以下命令执行此操作:
mysql_secure_installation
如下图所示回答所有问题:
Enter current password for root (enter for none):
Set root password? [Y/n]: N
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:
mysql -u root -p
登录后,使用以下命令为 Neos CMS 创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE neosdb;
MariaDB [(none)]> CREATE USER 'neos'@'localhost' IDENTIFIED BY 'mypassword';
接下来,使用以下命令授予对 Neos 数据库的所有权限:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neosdb.* TO 'neos'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
接下来,将数据库字符集更改为 utf8mb4,刷新权限,然后使用以下命令退出 MariaDB:
MariaDB [(none)]> ALTER DATABASE neosdb charset=utf8mb4;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
接下来,编辑 MariaDB 配置文件并进行一些更改:
nano /etc/mysql/mariadb.conf.d/50-server.cnf
添加以下行:
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_file_per_table = 1
innodb_default_row_format = dynamic
保存并关闭文件,然后重新启动 MariaDB 服务以应用更改:
systemctl restart mariadb
完成后,您可以继续下一步。
安装 Neos CMS
在开始之前,您需要将 Composer 安装到您的系统中。 Composer 是一个依赖管理器,用于安装 PHP 依赖项。
运行以下命令来安装 Composer:
curl -sS https://getcomposer.org/installer | php
您应该得到以下输出:
All settings correct for using Composer
Downloading...
Composer (version 2.4.1) successfully installed to: /root/composer.phar
Use it: php composer.phar
接下来,将 Composer 文件移动到系统位置:
mv composer.phar /usr/local/bin/composer
接下来,将目录更改为 Apache Web 根目录并使用以下命令下载 Neos CMS:
cd /var/www/html/
git clone https://github.com/neos/neos-base-distribution.git
接下来,重命名下载的目录,并运行 composer 命令来安装所有 PHP 依赖项:
mv neos-base-distribution neoscms
cd neoscms
composer install
接下来,为 Neos 目录设置适当的权限和所有权:
chown -R www-data:www-data /var/www/html/neoscms/
chmod -R 755 /var/www/html/neoscms/
完成后,您可以继续下一步。
为 Neos CMS 配置 Apache
接下来,您需要创建一个 Apache 虚拟主机配置文件来托管 Neos CMS。您可以使用以下命令创建它:
nano /etc/apache2/sites-available/neoscms.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
DocumentRoot /var/www/html/neoscms/Web
ServerName neos.example.com
<Directory /var/www/html/neoscms/Web/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/neos_error.log
CustomLog ${APACHE_LOG_DIR}/neos_access.log combined
<Directory /var/www/html/neoscms/Web/>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php [PT,L]
</Directory>
</VirtualHost>
保存并关闭文件,然后激活虚拟主机并使用以下命令启用 Apache 重写模块:
a2ensite neoscms.conf
a2enmod rewrite
接下来,重新启动 Apache 服务以应用更改:
systemctl restart apache2
您还可以使用以下命令检查 Apache 服务的状态:
systemctl status apache2
您应该得到以下输出:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-09-04 08:07:38 UTC; 8s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 22571 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 22577 (apache2)
Tasks: 6 (limit: 4579)
Memory: 14.7M
CPU: 128ms
CGroup: /system.slice/apache2.service
??22577 /usr/sbin/apache2 -k start
??22578 /usr/sbin/apache2 -k start
??22579 /usr/sbin/apache2 -k start
??22580 /usr/sbin/apache2 -k start
??22581 /usr/sbin/apache2 -k start
??22582 /usr/sbin/apache2 -k start
Sep 04 08:07:38 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
此时,Apache Web 服务器已配置为服务 Neos CMS。您现在可以继续下一步。
访问 Neos CMS
现在,打开您的网络浏览器并使用 URL http://neos.example.com 访问 Neos CMS。您将被重定向到以下页面:

单击转到设置。您应该会看到以下页面:

提供 SetupPassword.txt 文件中的设置密码,然后单击“登录”按钮。您应该会看到以下页面:

确保安装了所有必需的 PHP 扩展,然后单击“下一步”按钮。您应该会看到以下页面:

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

提供您的姓名、管理员用户名、密码,然后单击“下一步”按钮。您应该会看到以下页面:


单击转到后端。您应该会看到 Neos CMS 登录页面:

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

使用 Lets Encrypt 保护 Neos CMS
使用 Lets Encrypt Free SSL 保护您的网站是个好主意。首先,安装 Certbot 客户端来安装和管理 SSL。您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
安装后,运行以下命令以使用 Lets Encrypt SSL 保护您的网站:
certbot --apache -d neos.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):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 neos.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/neos-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/neos-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/neos-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 键为您的网站安装 Lets Encrypt SSL:
Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/neos.conf to ssl vhost in /etc/apache2/sites-available/neos-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://neos.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=neos.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/neos.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/neos.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
结论
恭喜!您已经在 Ubuntu 22.04 服务器上成功安装了带有 Apache 和 Lets Encrypt SSL 的 Neos CMS。您现在可以通过网络浏览器轻松创建和编辑您的网站。如果您有任何问题,请随时问我。