error_log logs/error.log error ;
pid logs/nginx.pid;
user www;
worker_processes auto;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
}
http {
client_body_buffer_size 1024k;
client_header_buffer_size 2k;
client_max_body_size 500m;
default_type application/octet-stream;
log_not_found off;
server_tokens off;
include mime.types;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
gzip_vary on;
#error_page 500 502 503 504 /50x.html;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server {
listen 80 default_server;
server_name localhost;
root /home/wwwroot/;
index index.php index.html index.htm;
location / {
index index.htm index.html index.php;
#如果文件不存在则尝试TP解析
try_files $uri /index.php$uri;
}
location ~ .+\.php($|/) {
# root /var/www/html/website;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffers 32 8k;
#设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,
#后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
#加载Nginx默认"服务器环境变量"配置
include fastcgi.conf;
}
}
include vhost/*.conf;
pid logs/nginx.pid;
user www;
worker_processes auto;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
}
http {
client_body_buffer_size 1024k;
client_header_buffer_size 2k;
client_max_body_size 500m;
default_type application/octet-stream;
log_not_found off;
server_tokens off;
include mime.types;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
gzip_vary on;
#error_page 500 502 503 504 /50x.html;
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server {
listen 80 default_server;
server_name localhost;
root /home/wwwroot/;
index index.php index.html index.htm;
location / {
index index.htm index.html index.php;
#如果文件不存在则尝试TP解析
try_files $uri /index.php$uri;
}
location ~ .+\.php($|/) {
# root /var/www/html/website;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffers 32 8k;
#设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,
#后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
#加载Nginx默认"服务器环境变量"配置
include fastcgi.conf;
}
}
include vhost/*.conf;
}
复制到nginx的配置文件,重启服务,直接就可以使用了(前提:安装完lnmp环境之后没有自定义过nginx文件,自定义过请把自定义的内容加到相应的地方)