如何在 Ubuntu 22.04 上使用 Nginx 安装 Fuel CMS 并加密货币 SSL
Fuel CMS 是一个用于网站的开源内容管理系统。 它基于 CodeIgniter PHP Web 框架,用于高级 Web 开发。 它可以帮助用户创建自定义模块并根据自己的要求查看和使用 CMS 部分。 它提供了一个简单且用户友好的 Web 界面,可以从任何设备管理网站。
本文将介绍如何在 Ubuntu 22.04 上使用 Nginx 和 Let’s Encrypt SSL 安装 Fuel CMS 系统。
先决条件
- 运行 Ubuntu 22.04 的服务器。
- 域名指向您的服务器IP。
- 服务器上配置了 root 密码。
更新系统
首先,建议将系统软件包更新到最新版本。 您可以使用以下命令更新它们:
apt-get update -y
apt-get upgrade -y
更新所有软件包后,您可以继续下一步。
安装 Nginx、MariaDB 和 PHP
接下来,您必须在系统中安装 Nginx Web 服务器、MariaDB、PHP 和其他 PHP 扩展。 您可以使用以下命令安装所有软件包:
apt-get install nginx mariadb-server php php-cli php-fpm php-mysqli php-curl php-gd php-xml php-common unzip -y
安装所有软件包后,编辑 php.ini 文件并更改一些默认 PHP 设置:
nano /etc/php/8.1/fpm/php.ini
更改以下行:
memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 date.timezone = UTC
保存并关闭文件,然后重新启动 PHP-FPM 服务以应用更改:
systemctl restart php8.1-fpm
配置 MariaDB 数据库
接下来,您需要为 Fuel CMS 创建数据库和用户。 首先,使用以下命令登录 MariaDB 控制台:
mysql
连接后,使用以下命令创建数据库和用户:
MariaDB [(none)]> CREATE DATABASE fuel;
MariaDB [(none)]> GRANT ALL ON fuel.* TO 'fuel'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
此时,MariaDB 已配置为 Fuel CMS。 您现在可以继续下一步。
安装燃油 CMS
首先,使用以下命令创建一个目录来存储 Fuel CMS 内容:
mkdir -p /var/www/html/fuel
接下来,导航到 Fuel CMS 目录并使用以下命令下载最新版本的 Fuel CMS:
cd /var/www/html/fuel
wget https://github.com/daylightstudio/FUEL-CMS/archive/master.zip
下载完成后,使用以下命令解压缩下载的文件:
unzip master.zip
接下来,使用以下命令将所有内容从提取的目录移动到当前目录:
mv FUEL-CMS-master/* .
接下来,编辑database.php 文件并定义数据库设置:
nano fuel/application/config/database.php
更改以下行:
$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'fuel', 'password' => 'password', 'database' => 'fuel', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE,
接下来,使用以下命令将 Fuel CMS 架构导入 Fuel 数据库:
mysql -u fuel -p fuel < fuel/install/fuel_schema.sql
接下来,编辑 MY_fuel.php 并启用管理员登录:
nano fuel/application/config/MY_fuel.php
将 FALSE 更改为 TRUE,如下所示:
$config['admin_enabled’] = TRUE;
保存并关闭文件,然后创建会话目录并设置适当的所有权:
mkdir -p /var/lib/php/session
chown -R www-data:www-data /var/lib/php/session
chown -R www-data:www-data /var/www/html/fuel
完成后,您可以继续下一步。
为 Fuel CMS 配置 Nginx
首先,创建一个 Nginx 虚拟主机配置文件来服务 Fuel CMS。
nano /etc/nginx/conf.d/fuel.conf
添加以下行:
server { listen 80; root /var/www/html/fuel; index index.php index.html index.htm; server_name fuelcms.example.com; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \.php${ include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
保存并关闭文件,然后使用以下命令验证 Nginx 是否存在语法错误:
nginx -t
您应该得到以下输出:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
接下来,重新启动 Nginx 服务以应用更改:
systemctl reload nginx
您现在可以使用以下命令验证 Nginx 的状态:
systemctl status nginx
您应该看到以下输出:
? nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2022-11-20 11:20:17 UTC; 8min ago Docs: man:nginx(8) Process: 77816 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS) Main PID: 76763 (nginx) Tasks: 2 (limit: 2242) Memory: 3.0M CPU: 62ms CGroup: /system.slice/nginx.service ??76763 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" ??77817 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" Nov 20 11:20:17 ubuntu2204 systemd[1]: Starting A high performance web server and a reverse proxy server... Nov 20 11:20:17 ubuntu2204 systemd[1]: Started A high performance web server and a reverse proxy server. Nov 20 11:28:14 ubuntu2204 systemd[1]: Reloading A high performance web server and a reverse proxy server... Nov 20 11:28:14 ubuntu2204 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
此时,Nginx 已配置为托管 Fuel CMS。 您现在可以继续访问 Fuel CMS。
访问 Fuel CMS Web 界面
现在,打开 Web 浏览器并使用 URL http://fuelcms.example.com/fuel 访问 Fuel CMS。 您将被重定向到 Fuel CMS 登录页面:
提供默认的管理员用户名和密码 admin,然后单击“登录”按钮。 您应该看到密码重置屏幕:
单击重置密码按钮。 您应该看到以下屏幕:
提供您的新密码,然后单击“保存”按钮以保存更改。 现在,单击仪表板按钮。 您应该在以下页面上看到 Fuel CMS 仪表板:
通过 Let’s Encrypt 保护 Fuel CMS
接下来,您需要安装 Certbot 客户端包来安装和管理 Let’s Encrypt SSL。
首先,使用以下命令安装 Certbot:
apt-get install python3-certbot-nginx -y
安装完成后,运行以下命令在您的网站上安装 Let’s Encrypt SSL:
certbot --nginx -d fuelcms.example.com
您将被要求提供有效的电子邮件地址并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx 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 Obtaining a new certificate Performing the following challenges: http-01 challenge for fuelcms.example.com Waiting for verification... Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/fuel.conf
接下来,选择是否将 HTTP 流量重定向到 HTTPS,如下所示:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 键完成安装。 您应该看到以下输出:
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/fuel.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://fuelcms.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=fuelcms.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/fuelcms.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/fuelcms.example.com/privkey.pem Your cert will expire on 2023-02-20. 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" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - 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 - We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
现在,您的网站已通过 Let’s Encrypt SSL 获得保护。 您可以使用 URL https://fuelcms.example.com 安全地访问它
结论
恭喜 您已在 Ubuntu 22.04 上成功安装了带有 Nginx 和 Let’s Encrypt SSL 的 Fuel CMS。 您现在可以尝试 Fuel CMS,探索其功能并开始托管您自己的网站或博客。 如果您有任何疑问,请随时问我。
资讯来源:由a0资讯编译自THECOINREPUBLIC。版权归作者A0资讯所有,未经许可,不得转载