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
ServerAlias 192.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的配置文件内容:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile off;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 40;
#gzip on;
server {
listen 80;
server_name 192.168.1.122;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root e:/svn;
index index.html index.htm;
}
location ~ \.php$ {
proxy_pass http://192.168.1.122:81;
}
location ~* \.(jpg|jpeg|gif|png)$ {
expires 30d;
}
location ~* \.(js|css)$ {
expires 1d;
}
}
}
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
评论: