其实我原本的标题是这样子的:《Windows+Nginx+PHP+MySQL+phpMyAdmin+Sanboxie+流量精灵+流量宝》=。=我怕吓到大家,就不好意思了…其实VPS在Windows下纯为了能运行老标题的后面的两个小东西,Nginx也只是为了节省内存而选择的,否则我就上Apache了。呵呵~没事,如果您也想配置这样的环境可以跟我一起来哦~
程序准备[本文所采用的程序均使用最新版:Nginx1.3.11,PHP5.4.11,MySQL5.6.10]:
Nginx:http://nginx.org/en/download.html
PHP:http://windows.php.net/download
MySQL:http://download.softagency.net/MySQL/Downloads/MySQL-5.6(未了避免官网要登陆下载,采用了镜像地址)
或使用一次性WGET命令:
|
wget
"http://nginx.org/download/nginx-1.3.11.zip"
"http://windows.php.net/downloads/releases/php-5.4.11-Win32-VC9-x86.zip"
"http://download.softagency.net/MySQL/Downloads/MySQL-5.6/mysql-5.6.10-win32.zip"
|
Notepad++:http://notepad-plus-plus.org/download(用于编辑UNIX格式的配置文件,如php.ini等…)
安装PHP运行环境:
很简单,把下载的文件直接解压出来,放到一个地方就好了,比如说我是放在C:\Aroma\php-5.4.11。备份php.ini-production,并重命名为php.ini。注意修改以下几个地方:
常规修改:
|
;
指定
doc_root
,即网站的根目录
:
doc_root
=
"C:\doc_root"
扩展存放目录
extension_dir
,
Windows下一般是
ext目录
:
extension_dir
=
"ext"
;
修改时区
:
date
.
timezone
=
Asia
/
Shanghai
|
Nginx环境专用修改:
|
enable_dl
=
On
cgi
.
force_redirect
=
0
cgi
.
fix_pathinfo
=
1
fastcgi
.
impersonate
=
1
cgi
.
rfc2616_headers
=
1
|
至此,PHP运行环境就这样配置完成。
同理,下载回来后解压到C:\Aroma\nginx-1.3.11,当然啦路径可以修改的。解压后进入目录,发现conf目录,毫不犹豫,进去,发现nginx.conf,毫不犹豫编辑=。=
常规配置:
1
2
3
4
5
6
7
8
9
10
11
12
|
# 启用错误日志
error_log
logs
/
error
.
log
;
# 启用GZIP压缩(放在http{}里面,sever{}之前)
gzip
on
;
gzip_min_length
1000
;
gzip_buffers
4
8k
;
gzip_http_version
1.1
;
gzip_types
text
/
plain
application
/
x
-
javascript
text
/
css
text
/
html
application
/
xml
;
# 修改编码,为了更好地兼容简化中文版Windows,若您用的是英文版Windows则可以修改为uft-8
charset
gbk
;
|
修改网站的根目录及首页文件;语句定位在server {}中:
|
location
/
{
# 把root后面的路径改为网站的根目录
root
"C:\doc_root"
;
# 添加index.php
index
index
.
html
index
.
htm
index
.
php
;
autoindex
on
;
}
|
FastCGI的配置:
搜索“# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000”,将整段话复制一次并修改,如下:
|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location
~
\
.
php
$
{
# root后面跟什么不用再解释了吧=。=
root
"C:\doc_root"
;
fastcgi_pass
127.0.0.1
:
9000
;
fastcgi_index
index
.
php
;
# 把"scripts"改为$document_root,指代的就是root 上面的目录
fastcgi_param
SCRIPT_FILENAME
$
document_root
$
fastcgi_script_name
;
include
fastcgi_params
;
}
|
至此Nginx配置也搞掂咯~开心吧~我也在您开心~
安装MySQL支持:
如果您下载的是msi扩展名的安装向导版那么您大可不必看下面的废话了~如果您和我一样不幸,下载的居然是zip手动安装版那就证明您是好人~大大的好人~除了有点蠢之外……当然啦~在本花七七大大的面前,蠢事犯得还不只这个…下面来说说怎么安装zip版MySQL。解压神马的不用说了吧,我这里是解压到C:\Aroma\mysql-5.6.10。备份my-default.ini,改名my.ini,如下修改:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
# MySQL官方文档里面好像没有提及这东西,但是Google告诉我最好还是添加一下又不会死~=。=
[
WinMySQLAdmin
]
Server
=
"C:/Aroma/mysql-5.6.10/bin/mysqld.exe"
[
mysqld
]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# "base"="基本","dir"="目录",意思就是MySQL的安装目录
basedir
=
"C:/Aroma/mysql-5.6.10"
# "data"="数据","dir"="2B么~看上面",意思就是网站的MySQL数据目录
datadir
=
"C:/Aroma/mysql-5.6.10/data"
# 端口...
port
=
3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
# 默认配置,理得它是啥干嘛,保留之~
sql_mode
=
NO_ENGINE_SUBSTITUTION
,
STRICT_TRANS_TABLES
|
进入CMD命令行环境,安装MySQL服务:
|
C
:
\
Documents
and
Settings
\
Administrator
>
cd
C
:
\
Aroma
\
mysql
-
5.6.10
\
bin
C
:
\
Aroma
\
mysql
-
5.6.10
\
bin
>
mysqld
--
install
mysql5
--
defaults
-
file
=
C
:
\
Aroma
\
mysql
-
5.6.10
\
my
.
ini
|
|
将收到提示:
Service
successfully
installed
.
|
这样,MySQL基本上配置完毕了,现在只要启动MySQL并且修改一下root密码增加安全性即可:
1、mysql -u root -p执行后由于默认没有密码,所以直接回车OK!
2、这里语句的默认密码是password,您就可以发挥您的聪明才智=。=~
3、语句记得带;哦~表示语句结束~
|
C
:
\
Documents
and
Settings
\
Administrator
>
cd
C
:
\
Aroma
\
mysql
-
5.6.10
\
bin
C
:
\
Aroma
\
mysql
-
5.6.10
\
bin
>
net
start
mysql5
C
:
\
Aroma
\
mysql
-
5.6.10
\
bin
>
mysql
-
u
root
-
p
MySQL
>
use
MySQL
;
MySQL
>
SET
PASSWORD
FOR
'root'
@
'localhost'
=
PASSWORD
(
'password'
)
;
MySQL
>
flush
privileges
;
MySQL
>
exit
;
|
好啦~MySQL基本也配置到这里了!接下来介绍一下怎么启动即可!
启动与关闭方法:
在桌面创建Start_Website.bat批处理,并下载RunHiddenConsole.exe解压放置于C:\Windows目录下,批处理内容如下:
|
@
echo
off
echo
Starting
Nginx
.
.
.
cd
C
:
\
Aroma
\
nginx
-
1.3.11
\
&&
RunHiddenConsole
.
exe
"C:\Aroma\nginx-1.3.11\nginx.exe"
echo
Starting
PHP
FastCGI
.
.
.
RunHiddenConsole
.
exe
c
:
\
Aroma
\
php
-
5.4.11
\
php
-
cgi
.
exe
-
b
127.0.0.1
:
9000
-
c
c
:
\
Aroma
\
php
-
5.4.11
\
php
.
ini
echo
Starting
MySQL
.
.
.
net
start
mysql5
|
您可能无法启动php-cgi.exe,别急,这是因为您的服务器上面没有安装VS2008运行库,只要你下载并安装即可运行即可:
http://download.microsoft.com/download/5/9/e/59e74271-2b59-49a1-b955-96b69cc34f38/vcredist_x86.exe
在桌面创建Shutdown_Website.bat批处理,内容如下:
|
@
echo
off
echo
Stopping
nginx
.
.
.
taskkill
/
F
/
IM
nginx
.
exe
>
nul
echo
Stopping
PHP
FastCGI
.
.
.
taskkill
/
F
/
IM
php
-
cgi
.
exe
>
nul
echo
Stopping
MYSQL
.
.
.
net
stop
mysql5
>
nul
exit
|
最后,送个探针检测的Panda Host VPS的性能吧:
本文参考的资料:
1.windows nginx php配置:http://ljl-xyf.iteye.com/blog/1327779
2.解压php-5.3.6 后,找不到php.ini-dist 文件,只有php.ini-development和php.ini-production:http://zhidao.baidu.com/question/241164634.html
3.系统无法执行指定的程序:http://www.cnnginx.com/?p=82
4.window安装mysql(zip、noinstall):http://www.jz123.cn/text/1522871.html
5.使用MySQL命令行修改密码: http://database.51cto.com/art/201010/229528.htm