Toggle navigation


WNMP镜像手册(Windows|PHP|Nginx)

Version 1.0.0

WNMP Stack(Windows-Nginx-MySQL-PHP)集成包是全球最流行的Web运行环境之一,基于免费、开源软件构建。框架中包括:Windows操作系统,Nginx Web服务器软件,MySQL数据库,PHP编程语言等四种核心组件以及其他相关辅助组件。通过组合、优化和兼容性处理,将所有组件打包成一个高性能、高集成性的Web运行环境解决方案包,保证能够兼容运行绝大部分PHP应用程序。

1、首页验证

使用浏览器打开首页demo:http://IP地址,首页正常显示,则表示环境安装成功。

2、 服务器情况

通过“首页”->“检查服务器情况”/“phpinfo”了解安装软件的详细信息:

3、数据库管理

通过“首页”->“APPLICATIONS”找到phpMyAdmin,进行数据库管理:

数据库默认用户/密码:root/websoft9。

 

Windows服务器上默认安装了firefox浏览器,可在桌面上使用该浏览器。

WAMP安装在C:websoft9nginxstack-*(*表示不同的版本号)。

首页对应目录:C:websoft9nginxstack*nginxhtml,该目录包含首页demo、phpinfo、探针等文件。

PHPINFO: http://IP地址/phpinfo.php

服务器情况查看:http://IP地址/tz.php

APPS目录:C:websoft9nginxstack*apps

 

软件集成:

   - Nginx 1.10.1
   - MySQL 5.6.30
   - PHP 5.6.22
   - PHPMyAdmin 4.6.2
   - ImageMagick 6.7.5
   - SQLite 3.7.15.1

服务随操作系统自动启动,如果手工修改配置参数后,需要重新启停服务。

方法一:在“开始”-> “管理工具”->“服务”中启停nginxstacknginx、nginxstackMysql、nginxstackPHP-CGI服务。

方法二:在C:websoft9nginxstack-1.10.1中双击打开manager-windows,启停nginxstacknginx、nginxstackMysql、nginxstackPHP-CGI服务。

方法三:在“开始”-> “所有程序”->“Bitnami NGNIX Stack”中找到“Bitnami NGNIX Stack Manager Tool”。

点击“Bitnami NGNIX Stack Manager Tool”,打开窗口,启停nginxstacknginx、nginxstackMysql、nginxstackPHP-CGI服务。

修改C:websoft9nginxstack-*nginxconfbitnami下的bitnami.conf 文件(红色字体区域是根目录),修改后重启Nginx服务
# HTTP server

server {
listen 80;
server_name localhost;

location / {
root html;
index index.html index.htm;
}

include "C:/websoft9/nginxstack-1.10.1/nginx/conf/bitnami/phpfastcgi.conf";

include "C:/websoft9/nginxstack-1.10.1/nginx/conf/bitnami/bitnami-apps-prefix.conf";
}

# HTTPS server

server {
listen 443 ssl;
server_name localhost;

ssl_certificate server.crt;
ssl_certificate_key server.key;

# http://nginx.org/en/docs/windows.html#known_issues
#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
root html;
index index.html index.htm;
}

include "C:/websoft9/nginxstack-1.10.1/nginx/conf/bitnami/phpfastcgi.conf";

include "C:/websoft9/nginxstack-1.10.1/nginx/conf/bitnami/bitnami-apps-prefix.conf";
}


include "C:/websoft9/nginxstack-1.10.1/nginx/conf/bitnami/bitnami-apps-vhosts.conf";

前提条件:国内服务器要进行域名备案,并配置好域名解析到该服务器IP

1、配置HOST文件

首先在系统盘下C:WindowsSystem32Driversetc(见下面红色字体)进行配置.

假设要配置的域名为test.websoft9.cn和demo.websoft9.cn:

——————————————————————————————————–

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

127.0.0.1 test.websoft9.cn

——————————————————————————————————–

 

2、配置vhost文件(配置前注意将原来文件备份,以预防修改失败快速恢复)

1) 快速修改网站根目录,参考前面一节“快速修改网站根目录”即可,如根目录不变则无须修改,本例中假设网站根目录是C:/test

2)配置C:websoft9nginxstack-*nginxconfbitnami下面的bitnami-apps-vhosts.conf文件(见红色字体):

——————————————————————————————————–
server {

listen 80;
root “C:/websoft9/nginxstack-1.10.1/apps/demo/htdocs”;
server_name test.websoft9.cn;

include “C:/websoft9/nginxstack-1.10.1/apps/demo/conf/nginx-app.conf”;
}

server {

listen 443 ssl;
root “C:/websoft9/nginxstack-1.10.1/apps/demo/htdocs”;
server_name test.websoft9.cn;

ssl_certificate “C:/websoft9/nginxstack-1.10.1/apps/demo/conf/certs/server.crt”;
ssl_certificate_key “C:/websoft9/nginxstack-1.10.1/apps/demo/conf/certs/server.key”;
# http://nginx.org/en/docs/windows.html#known_issues
#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

include “C:/websoft9/nginxstack-1.10.1/apps/demo/conf/nginx-app.conf”;
}

——————————————————————————————————–

3、重启Nginx服务,然后就可以通过域名访问服务器了。

client_max_body_size为例,修改C:websoft9nginxstack-*nginxconfnginx.conf文件

比如修改client_max_body_size 为 20MB:

client_max_body_size 20m;

修改完成后重启nginx服务。

How to create a Virtual Host?

To create virtual hosts for an application with Nginx lets you configure virtual hosts for your applications, such that you can access them at (for example) http://appname.example.com instead of http://example.com/appname. Select your platform below for detailed instructions.

1. Edit the installdir/nginx/conf/bitnami/bitnami-apps-prefix.conf file and comment out the line below so that it looks like this:

#include "installdir/apps/APPNAME/conf/nginx-prefix.conf";

2. Include the virtual host configuration file for your application in the installdir/nginx/conf/bitnami/bitnami-apps-vhosts.conf file:

include "installdir/apps/APPNAME/conf/nginx-vhosts.conf";

3. Update the application’s nginx-app.conf file at installdir/apps/APPNAME/conf/nginx-app.conf with the revised application URL if necessary. For example, you might replace the line

rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last;

with

rewrite ^/(.+)$ /index.php?q=$1 last;

4. Update the application configuration to reflect the revised URL if necessary. This is an application-specific step and different applications will require different changes. For example, if you are using WordPress, you would need to edit the installdir/apps/wordpress/htdocs/wp-config.php file and add the following lines:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');                   
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/'); 

5. Restart the Nginx server using the graphical manager or control script.