编辑 Nginx.conf

输入 nano -c /etc/nginx/nginx.conf -c 这个属性是为了让nano在打开文件时显示行号,understand? 在 Virtual Host Config 的注释内容下,大概56行,添加 include /etc/nginx/conf.d/*.conf; 2024-02-06T06:07:37.png

接下来就是在该位置下创建配置文件,后缀为.conf 配置文件的格式如下

server {
    listen 端口 ssl default_server;
    listen [::]:端口 ssl default_server;
    server_name 网站域名;
    ssl_certificate 证书文件路径;
    ssl_certificate_key 私钥文件路径;    
    root 网站根目录;
    index index.php;
    location / {
        index index.php index.html;
        if ( !-e $request_filename){
            rewrite ^/(.*)$ /index.php?s=$1 last;
            break;
        }
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires 30d;
    }
    location ~ .*\.(js|css)?$ {
        expires 30d;
    }
    location ~ .*\.(php|php5)?$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
}

保存退出,重启Nginx php即可 service php7.4-fpm restart service nginx restart