centos6搭建智能Nginx服務器
阿新 • • 發佈:2019-03-21
配置 lis dex 多站點 編譯 sendfile efault list cal 下載Nginx包
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;
}
}
下載地址: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;
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服務器