linux下nginx配置host使用IP和端口访问
server {
listen 81; #端口号
server_name 47.110.242.239; #主机名
index index.php index.html index.htm;
root /usr/local/nginx/html/qpl_system/;
error_page 404 /404.html; # 错误页面
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+?\.php)(/.+)$") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 1d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
location /ngx_status {
stub_status on;
access_log off;
#allow 127.0.0.1;
#deny all;
}
error_log /usr/local/nginx/html/qpl_system/qpl_error.log;
access_log /usr/local/nginx/html/qpl_system/qpl_access.log;
}