java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

Nginx 配置文件2018-11 Centos 7.4

简单配置

 server {
        listen       81;
        server_name  java-er.com;
        root         /www/java-er.com;

        location / {
                index index.html index.htm index.php;
        }

        location ~ \.php$ {
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

Nginx SSl

ssl                on;
        ssl_certificate      /www/javaer.com/ssl/full_chain.pem;
        ssl_certificate_key   /www/javaer.com/ssl/private.key;
        ssl_session_timeout  5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

WordPress 的URLREWRITE

if (!-e $request_filename){
rewrite (.*) /index.php;
}

完整配置

 server {
        listen       80;
	listen  443 ssl; #监听两个端口
        server_name  java-er.com;
        root         /www/javaer.com;
	 ssl_certificate      /www/javaer.com/ssl/full_chain.pem;
        ssl_certificate_key   /www/javaer.com/ssl/private.key;

        location / {
		index index.html index.htm index.php;


if (!-e $request_filename) {
    rewrite (.*) /blog/index.php;
}

       }

	location ~ \.php$ {
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include /etc/nginx/fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
	}
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

php-fpm的理解

1. 客户端通过http协议访问网站域名

2. Nginx接受请求,并路由转到index.php

3. 加载fastcgi模块

4. Fastcgi监听127.0.0.1:9000地址

5. 然后访问到达127.0.0.1:9000

6. php-fpm监听127.0.0.1:9000,也就接收到了请求

7. Fpm的master主进程,分配子进程去处理请求

8. 处理完成后,返回结果给nginx

9. Nginx通过http协议响应给客户端


This entry was posted in Linux and tagged , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/nginx-config-file-centos74/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply