debian lighttpd php ssl
apt update && sudo apt upgrade
systemctl start lighttpd
apt-get install php php-cgi php-fpm php-mysql
nano /etc/lighttpd/conf-available/wordpress.conf
apt-get install lighttpd
安装完成后,启动并启用该服务。
systemctl enable lighttpd
nano /etc/php/*/fpm/php.ini
进行以下更改:
cgi.fix_pathinfo=1(可将参数改为0)
file_uploads = On
upload_max_filesize = 100M
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
max_execution_time = 360
date.timezone = Africa/Nairobi
一旦进行了所需的更改,您需要将 Lighttpd 配置为使用 PHP-FPM 而不是默认的 PHP-CGI
进行以下更改:
nano /etc/php/7.4/fpm/pool.d/www.conf
listen = /run/php/php-fpm.sock
改为
listen = 127.0.0.1:9000
systemctl restart php*-fpm.service
现在修改 Lighttpd 配置以使用 PHP-FPM。
sudo vim /etc/lighttpd/conf-available/15-fastcgi-php.conf
在打开的文件中,
进行以下更改: 将
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/var/run/lighttpd/php.socket",
改为
"host" => "127.0.0.1",
"port" => "9000",
现在保存文件并启用 FastCGI 和 FastCGI-PHP 模块
lighty-enable-mod fastcgi
lighty-enable-mod fastcgi-php
重新启动网络服务器。
sudo systemctl restart lighttpd
创建虚拟主机文件
在文件中,添加以下行。
$HTTP["host"] == "wordpress.8bto.com" {
server.document-root = "/var/www/html/wordpress"
server.errorlog = "/var/log/lighttpd/wordpress-error.log"
}
保存文件并启用该站点,
如下所示:
ln -s /etc/lighttpd/conf-available/wordpress.conf /etc/lighttpd/conf-enabled/
使用 SSL 保护 Lighttpd
apt update
apt install certbot -y
certbot certonly --webroot -w /var/www/html/wordpress/ -d wordpress.8bto.com
图中第一个是填E-mail,后面直接是,就OK。
现在域拥有 SSL 证书。将这些文件合并为一个文件。
cat /etc/letsencrypt/live/file.8bto.com/cert.pem /etc/letsencrypt/live/file.8bto.com/privkey.pem | tee -a /etc/letsencrypt/live/file.8bto.com/web.pem
现在您需要编辑虚拟主机文件以容纳证书。
将之前的配置文件
/etc/lighttpd/conf-enabled/wordpress.conf
改成下面的:
$HTTP["host"] == "file.8bto.com" {
server.document-root = "/data/www/file"
}
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/file.8bto.com/web.pem"
ssl.ca-file = "/etc/letsencrypt/live/file.8bto.com/chain.pem"
server.name = "file.8bto.com"
server.document-root = "/data/www/file"
server.errorlog = "/var/log/lighttpd/file-error.log"
accesslog.filename = "/var/log/lighttpd/file_access.log"
}
$HTTP["scheme"] == "http" {
$HTTP["host"] == "file.8bto.com" {
url.redirect = ("/.*" => "https://file.8bto.com$0")
}
}
保存文件并重新启动 Lighttpd。
systemctl restart lighttpd
可能会遇到的问题:
将下面的模块添加到lighttpd.conf中即可。
"mod_openssl",
"mod_accesslog",
"mod_rewrite",
验证 Certbot 自动续订
运行以下命令模拟 SSL 证书的自动续订来测试证书续订
certbot renew --dry-run
评论