Nginx
1 前言
一个问题,一篇文章,一出故事。
本章将完成Nginx与PHP-FPM的集成。
2 最佳实践
2.1 安装配置PHP-FPM环境
2.2 安装配置Nginx
2.2.1 安装软件包
apt install -y nginx
然后,你需要使用如下命令确认启动并设置服务自启动,
systemctl status nginx systemctl enable nginx
2.2.2 创建虚拟服务器
vim /etc/nginx/conf.d/www.cmdschool.org_443.conf
加入如下配置,
server {
listen 443 ssl;
server_name www.cmdschool.org;
ssl_certificate wildcard.cmdschool.org-2025-nginx.crt;
ssl_certificate_key wildcard.cmdschool.org-2025.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /var/www/www.cmdschool.org;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /var/www/www.cmdschool.org;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name www.cmdschool.org;
return 301 $scheme://www.cmdschool.org$request_uri;
}
重载服务使配置生效,
systemctl reload nginx
2.2.3 测试配置
echo '<?php phpinfo(); ?>' > /var/www/www.cmdschool.org_443/index.php
http://www.cmdschool.org/index.php
没有评论