nginx+php+redis+ssl 配置

Posted klvchen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx+php+redis+ssl 配置相关的知识,希望对你有一定的参考价值。

php的接触得很少,记录一下
环境:CentOS 7.4

安装软件

# 安装 nginx
yum install nginx

# 配置PHP7的源,安装 PHP 7.0 及扩展
yum install epel-release
yum install php70w-fpm php70w-cli php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel 

# 安装 redis 及 redis 扩展
yum install php70w-pecl-redis redis

配置网站 /etc/nginx/conf.d/www.conf

server {
        listen 80;
        server_name klvchen.com www.klvchen.com;
        rewrite ^(.*)$ https://$host$1 permanent;
}
server {
        listen 443 ssl http2;
        server_name klvchen.com www.klvchen.com;

        ssl_certificate /etc/nginx/cert/3177653_klvchen.com.pem;
        ssl_certificate_key /etc/nginx/cert/3177653_klvchen.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_session_cache shared:SSL:1m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        fastcgi_param HTTPS on;
        fastcgi_param HTTP_SCHEME https;

        root /data/web/thinkphp_5.0.15_full/public;
        location / {
                index index.html index.php;
                if (!-e $request_filename) {
                         rewrite ^/(.*)$ /index.php?s=$1 last;
                }
        }

        location ~ .php(.*)$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                include fastcgi_params;
        }
}

测试 phpinfo.php

<?php
    phpinfo();
?>

以上是关于nginx+php+redis+ssl 配置的主要内容,如果未能解决你的问题,请参考以下文章

nginx配置phpredisadmin无法正常运行

nginx + php + https 配置

nginx配置ssl

CentOS下 Nginx+PHP配置Session+Redis

nginx配置ssl证书

Linux-Nginx-Nginx配置ssl