6

安装 Ubuntu 22.04 (LTS), Webmin, Nginx, MariaDB, PHP8.1-FPM,Perl-Fastcgi 到...

 1 year ago
source link: https://seo.g2soft.net/2022/05/15/ubuntu-2204-lts-webmin-nginx-part5.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

安装 Ubuntu 22.04 LTS, Webmin, Nginx, MariaDB, PHP8.1-FPM,Perl-Fastcgi 到 DigitalOcean 的 VPS上。

之前介绍了如何在 DigitalOcean 创建新 VPS。并且完成基本的 Ubuntu 22.04 LTS的系统。然后介绍了如何安装 Webmin 主机控制面板,时区设置和 SSH 的安全设置。再之后说明一下如何用之前的新添加的用户来安装 Nginx Web 服务器和 MairaDB 数据库服务器。以及安装完 php 语言和 SSL 证书的申请。

现在要来介绍一下如何配置 nginx了。

修改 Nginx 配置文件,以满足证书的使用之前,先执行一个命令,来生成一个4096位的 dhparam 文件。

cd ~/ssl
openssl dhparam -out dhparam.pem 4096

需要等待一段时间,这个命令会执行比较长时间。

配置 https 主机

先来确认各个部分的版本信息,下面要用到。

davidyin@fig:~/ssl$ nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
davidyin@fig:~/ssl$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
davidyin@fig:~/ssl$

配置参数的来源根据 Mozilla SSL Configuration Generator 这个生成器来产生。

mozilla-ssl-config-nginx-2204.jpg

我会建议采取 Modern 方式的配置。

主机配置文件做相应的修改, http 网站重定向到 https。 采用 http2,还有就是 HSTS 与载入配置,最后完整的 u22.webexample.win 的配置文件,可以到 gist 查看,仅供参考。

SSL Labs 检测 SSL的配置,评分得到 A。

ssllab-rating-a-2204.jpg

安装 Perl-Fastcgi

下面是对我而言很重要的语言支持,因为我有用 MovableType blog 系统,SEO网站优化 就是用它搭建的。而它是由 perl 语言支持的。

libfcgi-perl 可能已经有了,但下面还是再执行一遍安装,以防缺失。

sudo apt install libfcgi-perl
sudo apt install spawn-fcgi fcgiwrap

然后执行下面的命令,来启动服务。

sudo service fcgiwrap restart

最后在 Nginx 的配置文件中添加下面这块。

location ~ \.pl|cgi$ {
   fastcgi_pass  unix:/var/run/fcgiwrap.socket;
   fastcgi_index index.pl;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include fastcgi_params;
   }

保存配置文件并重启 Nginx 服务。

接下来要测试,是否可以让 perl 文件运行。

新添加一个文件到 /home/davidyin/u22.webexample.win/index.pl

内容如下:

index_pl.txt

在服务器上的文件后缀名必须是 pl,然后给与可执行权限。

chmod 755 index.pl

在浏览器中输入 https://u20.webexample.win/index.pl

perl-language-check-2204.jpg

看到上面的信息,就可以证明 Perl 可以正常地在网站执行。

到目前为止,已经配置好一个 DigitalOcean 的 VPS,安装好了 Ubuntu 22.04 Lts,Webmin 管理控制面板,以及 Nginx web 服务器,MariaDB 数据库服务器,php8.1-fpm 服务,Perl-Fastcgi 服务,免费的 SSL 证书。配置好了一个测试网站。

那么之后,需要安装那些由 php 编写的网站程序, Perl 编写的网站程序,都可以安装了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK