安哥网络 发表于 2013-12-11 19:16:07

windows 2003下搭建nginx+apache

在windows 2003下成功让nginx以系统服务启动了之后,就有这个想法nginx在windows 2003下做前端缓存静态文件,让apache做后端处理php.因为以前做过apache反向代理,所以这次做起来还是很顺手.好了,看文章吧.
系统:windows 2003
ip:192.168.1.122
软件:nginx,apache,php,mysql

1.安装apache,php,mysql,nginx
这步我就不做了,没有什么意思,各位请自己去搜索安装教程.

2.修改apache和nginx的配置文件

apache的配置文件内容,就修改端口号和做个虚拟主机:

Listen 81

<VirtualHost 192.168.1.122:81>
ServerName   192.168.1.122:81
ServerAlias192.168.1.122
DocumentRoot e:/svn
<Directory "e:/svn">

    Options Indexes FollowSymLinks
    AllowOverride None

    Order allow,deny
    Allow from all

</Directory>
DirectoryIndex admin_login.php index.php
</VirtualHost>

nginx的配置文件内容:

#usernobody;
worker_processes1;

#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;

#pid      logs/nginx.pid;

events {
    worker_connections1024;
}


http {
    include       mime.types;
    default_typeapplication/octet-stream;

    sendfile      off;
    #tcp_nopush   on;

    #keepalive_timeout0;
    keepalive_timeout40;

    #gzipon;

    server {
      listen       80;
      server_name192.168.1.122;

      #charset koi8-r;

      #access_loglogs/host.access.logmain;

      location / {
            root   e:/svn;
            indexindex.html index.htm;
      }

      location ~ \.php$ {
             proxy_passhttp://192.168.1.122:81;
      }
      location ~* \.(jpg|jpeg|gif|png)$ {
             expires30d;
      }
      location ~* \.(js|css)$ {
             expires1d;
      }
    }
}

3.启动nginx和apache(我的nginx已经做成windows的服务)

net start nginx
net start apache2.2

4.在e盘创建测试的文件

上面的配置文件里指明的路径是e:/svn,这里自己创建个文件夹,然后在里面再创建个index.htm文件,输入内容 welcome to my webserver! 这是为了区别nginx的Welcome to nginx!

5.在浏览器里测试,输入http://192.168.1.122,出现welcome to my webserver! 说明配置是成功的,好了,就到这里吧,毕竟简单也没有什么好讲的了,有兴趣的可以在这内容上进行更多的研究,这些就要靠大家自己了.

ps:最后再送上2个小脚本吧

启动nginx:

@echo off
net start nginx
pause

停止nginx:

@echo off
net stop nginx
taskkill /F /IM nginx.exe>null
pause
摘自:http://blog.slogra.com/post-3.html

页: [1]
查看完整版本: windows 2003下搭建nginx+apache