修的了电脑 敲得了代码
     写得了前端 稳得住后端

windows下 配置 nginx前端apache后端

搞了好多天。如果还没有配置好 nginx环境和apache环境的 请看以下教程。

windows 2008下配置nginx+php环境

windows 2008 64位系统apache+php+mysql环境

大家看看 我的nginx配置

 

server {
listen 83;
server_name limoon.com;
location / {
root E:/jq/jiduu;
include E:/jq/jiduu/.htaccess;

index index.php index.html;
access_log D:/wo/../host.access.log ;(填上你具体的地址)
error_log D:/wo/../error_log.log; (填上你具体的地址)

# Nginx找不到文件时,转发请求给后端Apache
error_page 404 @proxy;

# css, js 静态文件设置有效期1天
location ~ .*\.(js|css)$ {
access_log off;
expires 1d;
}

# 图片设置有效期3天
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
access_log off;
expires 3d;
}
}

# 动态文件.php请求转发给后端Apache
location ~ \.php$ {
#proxy_redirect off;
#proxy_pass_header Set-Cookie;
#proxy_set_header Cookie $http_cookie;

# 传递真实IP到后端
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://127.0.0.1:100;
}

location @proxy {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://127.0.0.1:100;
}
# 防止直接访问 .htaccess 文件,建议开启
location ~ /.ht {
deny all;
}
}

 

 

这是我的apache配置

 

#其中一个虚拟主机
<VirtualHost *:100>
#设置管理员,有时会在出错的时候会显示
ServerAdmin admin@admin.com
#这个虚拟主机的目录
DocumentRoot "E:/../u"
#主机名,用于标记不同的虚拟主机名称
ServerName admin.com
#这个虚拟主机的使用域名
ServerAlias admin.com www.admin.com
#设置访问日志地址
ErrorLog "D:/wo/../errorlog.log"
CustomLog "D:/wo/../access.log" common
</VirtualHost>

 

总的来说:让nginx监听80端口  让apache监听非80端口如(端口100)

 

配置完之后,重启两个web环境。

 

如何检测已经成功了。自己看日志。

 

赞(0)
未经允许不得转载:流云溪|码农 » windows下 配置 nginx前端apache后端