server
{
listen 80 default;
server_name lacoste-******.shopex123.com;
location / {
proxy_pass http://127.0.0.1:9501;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 这是是 域名转发到本地端口号请求。 把 lacoste-hyt-test.shopex123.com 转发至本地端口号 http://127.0.0.1:9501;
index index.php;
root /data/httpd/hyperfmember/public;
location ~ .*\.php.*
{
include php_fcgi.conf;
include pathinfo.conf;
}
# 引入哪个版本php
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~* \.(ini|sql|conf|bak)$ {
return 404;
}
location ~* ^/(themes|images|logs|data|demo|wap_themes)/.*\.(php|php5)$ {
deny all;
}
location ~ /\.(svn|git|)/ {
deny all;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log /var/log/nginx/access.log access;
#access_log off;
}
引入PHP版本的文件
php_fcgi.conf 文件内容如下
fastcgi_pass 127.0.0.1:9000;// php 进程端口号
fastcgi_index index.php;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
nginx 和 apache 的区别
1. nginx 多进程 IO多路复用模型
apache 是多进程同步阻塞
nginx 负载均衡能力 和 反向代理。 抗压。轻量级
apache 动态反向代理 ,稳定性强
nginx 可以设置服务器 请求速率 某个地址请求速率 设置 每秒一次 缓存5次请求,如果超过五次报503