• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

centos6搭建智能Nginx服务器

Centos技术 liubingjie771 87次浏览 已收录 0个评论

下载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;
}

VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明centos6搭建智能Nginx服务器
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址