Build an Nginx server in windows

Source: Internet
Author: User

1. Prepared files:

Nginx: http://sysoev.ru/nginx/nginx-0.8.16.zip

PHP: http://cn.php.net/distributions/php-5.2.11-Win32.zip

MySQL: http://download.mysql.cn/download_file/zip/5.0/mysql-5.0.22-win32.zip

2. nginx requires cgi php, so the following points are important. Otherwise, nginx cannot open the php file:

Enable_dl = On
Cgi. force_redirect = 0
Cgi. fix_pathinfo = 1
Fastcgi. impersonate = 1
Cgi. rfc2616_headers = 1

3. Start Nginx and PHP:

It is easy to start nginx. you can double-click nginx.exe in the nginxdirectory. However, the cgi method is required for php startup, which is special. I downloaded runhiddenconsole.exe by referring to the local file on the network. The cmd window executed by this tool will be closed automatically. Otherwise, you will see that a CMD window is always shaking and the header will be dizzy.

Create start_php.bat to start php. The file content is as follows:

@ Echo off
Echo Starting PHP FastCGI...
RunHiddenConsole.exe d: phpphp-cgi.exe-B 127.0.0.1: 9000-c d: phpphp. ini

Create stop_nginx.bat to disable php and nginx processes. The file content is as follows:

@ Echo off
Echo Stopping nginx...
Taskkill/F/IM nginx.exe> nul
Echo Stopping PHP FastCGI...
Taskkill/F/IM php-cgi.exe> nul
Exit

4. nginx configuration file: (D: ginxconfg#. conf)

# 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 64;
}


Http {
Include mime. types;
Default_type application/octet-stream;

# Log_format main $ remote_addr-$ remote_user [$ time_local] "$ request"
# $ Status $ body_bytes_sent "$ http_referer"
# "$ Http_user_agent" "$ http_x_forwarded_for ";

# Access_log logs/access. log main;

Sendfile on;
# Tcp_nopush on;

# Keepalive_timeout 0;
Keepalive_timeout 65;

# Gzip on;

Server {
Listen 80;
Server_name localhost;

Charset gbk;

# Access_log logs/host. access. log main;

Location /{
Root e: www;
Index index.html index.htm index. php;
Autoindex on;
}

# Error_page 404/404. html;

# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}

# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ . Php $ {
# Proxy_pass http: // 127.0.0.1;
#}

# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Location ~ . Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
# Include fastcgi_params;
#}
Location ~ . Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME e: www $ fastcgi_script_name;
Include fastcgi_params;
}
# Deny access to. htaccess files, if Apaches document root
# Concurs with nginxs one
#
# Location ~ /. Ht {
# Deny all;
#}
}


# Another virtual host using mix of IP-, name-, and port-based configuration
#
# Server {
# Listen 8000;
# Listen somename: 8080;
# Server_name somename alias another. alias;

# Location /{
# Root html;
# Index index.html index.htm;
#}
#}


# HTTPS server
#
# Server {
# Listen 443;
# Server_name localhost;

# Ssl on;
# Ssl_certificate cert. pem;
# Ssl_certificate_key cert. key;

# Ssl_session_timeout 5 m;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.