码迷,mamicode.com
首页 > 其他好文 > 详细

centos6搭建智能Nginx服务器

时间:2019-03-20 23:29:49      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:web   www   配置   default   rip   支持   connect   listen   PHP编程   

下载Nginx包
下载地址:http://nginx.org/download/
  • 下载后解压nginx到/usr/local/后,执行编译,编译时需要预先加模块;

通过Nginx支持PHP编程

本人通过yum源安装php-fpm

配置Nginx.conf文件

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 10080;
server_name ly2016.club www.ly2016.club;
root /liuhome/nginx/html;
index index.html index.htm index.php;
location / {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:19001;
}
include /usr/local/nginx/conf.d/*.conf;
server {
listen 10080 default_server;
servername ;
return 403;
}
}

解读Nginx.conf中的信息

多域名绑定进行限制域名模式

server {
listen 10080 default_server;
server_name _;
return 403;
}

扩展名PHP可以配置PHP的支持

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:19001;
}

支持多站点的多个配置conf文件

include /usr/local/nginx/conf.d/*.conf;

多站点的某配置conf文件

WEBSVN站点的配置文件

server {
    listen       10080;
    server_name  svn.ly2016.club;
    root   /liuhome/nginx/websvn;
    index  index.html index.htm index.php;
    include /usr/local/nginx/conf/default.conf.d/*.conf;
    location / {
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

include /usr/local/nginx/conf.d/php.conf.bak;
}

Books站点的配置文件

server {
    listen       10080;
    server_name  book.ly2016.club;
    root   /liuhome/nginx/books;
    index  index.html index.htm index.php;
    include /usr/local/nginx/conf/default.conf.d/*.conf;
    location / {
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

include /usr/local/nginx/conf.d/php.conf.bak;

}

单独设置PHP语言文件

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:19001;
}

centos6搭建智能Nginx服务器

标签:web   www   配置   default   rip   支持   connect   listen   PHP编程   

原文地址:https://blog.51cto.com/liubingjie771/2366273

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!