操作环境:
- 硬件:华为云服务器
- 操作系统:Rocky Linux 9.0 64bit
- 服务器软件:nginx 1.24.0,php 8.2.6,openssl 3.0.7
问题描述
- 启用SSL前,用浏览器访问站点正常,启用ssl后,用浏览器访问站点( index.php),提示找不到文件。
- 用指令 systemctl status php-fpm查看php-fpm服务状态,显示正常。
- 用指令 netstat -tunlp | grep 9000查看php-fpm服务监听端口,显示正常。
- 用指令 systemctl status nginx.service查看nginx服务状态,显示正常。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# systemctl status nginx.service ● nginx.service - nginx Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled) Drop-In: /usr/lib/systemd/system/nginx.service.d └─php-fpm.conf Active: active (running) since Tue 2023-05-23 13:22:55 CST; 7min ago Process: 3108 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS) Main PID: 3109 (nginx) Tasks: 3 (limit: 23205) Memory: 3.9M CPU: 67ms CGroup: /system.slice/nginx.service ├─3109 "nginx: master process /usr/local/nginx/sbin/nginx" ├─3110 "nginx: worker process" └─3111 "nginx: worker process" May 23 13:22:55 hecs-288529 systemd[1]: Starting nginx... May 23 13:22:55 hecs-288529 systemd[1]: Started nginx. |
解决方案
- 修改/usr/local/nginx/conf/nginx.conf配置文件。将以下关于php的设置内容,从http server复制到https server中。
1 2 3 4 5 6 7 8 9 10 11 |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
- 运行指令 sudo systemctl restart nginx.service,重启nginx服务。
- 再次访问站点,一切OK。
This is a demo advert, you can use simple text, HTML image or any Ad Service JavaScript code. If you're inserting HTML or JS code make sure editor is switched to 'Text' mode.