nginx基本配置文件

liuqiang 2021年06月29日 28次浏览

Nginx 和web 服务介绍

Nginx 支持 HTTP/HTTPS/电子邮件代理协议

OpenResty软件的下载和安装
openResty 是基于 Nginx和Lua实现的Web应用网关,集成了大量的第三方模块
OpenResty的配置文件
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

yum install openresty

/usr/local/openresty/nginx/conf/nginx.conf

service openresty start

使用 OpenResty 配置域名虚拟主机

nginx.conf

 # nginx 运行时占用的进程数
 worker_processes 1;
 error_log logs/error.log notice;
 # pid  logs/pid;  #nginx的进程号写入哪个文件
 events {
   worker_connections 1024;
 } 
 http {
   include  mime.types;
   default_type application/octet-stream;  
   #log_format main
   sendfile   on;
   tcp_nopush on;
   keepalive_timeout 65;
   gzip  on;
   server {
       listen 80;
       server_name www.servera.com;
        
       location / {
          root html;
          index  index.html; 
        }    
		
      }
   server {
       listen 80;
       server_name www.servera.com;
        
       location / {
          root html;
          index  index.html; 
        }  
        # php 请求
        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;
        }   
		
      }
   
 }

nginx -t 测试配置文件
nginx -s stop
nginx -s reload