The method of installing Php+nginx under Windows7 _nginx

Source: Internet
Author: User

This paper describes the method of installing Php+nginx under Windows7. Share to everyone for your reference, specific as follows:

The first is to install PHP

I've already installed the PHP5.2.11 locally. The same is not installed, the official website download a Windows binary package on the line.

Run the PHP5.2.11 installation file directly, then select Modify, Next, select Other CGI, and the extension of the selected installation appears,

I chose GD2, Mysql, Mysqli, PDO, Pdo_mysql. Next, install, install, complete.

Then run PHP in fastcgi mode

Because PHP is php-cgi.exe, run it at the command line.

Php-cgi.exe-b 127.0.0.1:9000

Pop up a command line window, and be careful not to turn off (the solution below).

Then install Nginx

There's a ready-made Windows Installer on the official website, just down.

Nginx's Chinese wiki http://wiki.nginx.org/NginxChs

Stable security considerations for the current stable version of the Nginx/windows 0.7.63 (update record) (October 26, 2009)

Download is a compressed package, directly unzip the copy to a directory on the line,

I am installed in D:\nginx-0.7.63

Double-click Nginx.exe, and it runs without the need for installation.

I was installed in D:\nginx-0.7.63

Then enter the http://localhost/display in the browser

Welcome to nginx!

Indicates that the Nginx is running properly.

Configure Nginx

My site and directory are d:/www directories.

The configuration is not very complicated, no comment.

D:\nginx-0.7.63\conf under the nginx.conf, Notepad open.

Found it

#pid    Logs/nginx.pid;

Remove the previous comment

Found it:

Location/{
  root  html;
  Index index.html index.htm;
}

Modified into:

Location/{
  root  d:/www;
  Index index.html index.htm index.php;
}

Found it:

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

The previous comment is removed and modified into

Location ~ \.php$ {
  root      d:/wwwroot;
  Fastcgi_pass  127.0.0.1:9000;
  Fastcgi_index index.php;
  Fastcgi_param script_filename d:/wwwroot/$fastcgi _script_name;
  Include    fastcgi_params;
}

Restart Nginx

The configuration file needs to be reloaded because the Nginx configuration file has been modified.

Nginx-s Reload

Several additional command parameters for Nginx

Nginx-s Stop  //pause
Nginx-s quit   //exit Nginx

The above commands require #pid logs/nginx.pid; The previous annotation is removed and the PID of the current nginx process is saved in the Logs/nginx.pid file.

A few other tips

Force end Process command with cmd command line


 

(sometimes end nginx, this command works better)

You can turn off all the nginx processes.

The command to close fastcgi is similar

taskkill/f/im php-cgi.exe > nul

In the site root directory, put a phpinfo file, without error, you can see the current site configuration information.

Solve the fastcgi way to run PHP when the cmd window problem.

The method is simple to start with a VBS script to solve. This method is much simpler than using third party software (such as RunHiddenConsole.exe) on the web.

Specific code:

Set wscriptobj = CreateObject ("Wscript.Shell")
wscriptobj.run "Php-cgi.exe-b 127.0.0.1:9000", 0

Save you to the PHP directory, named Start_fastcgi.vbs. Double-click to run it.

I hope this article will help you with your Nginx server configuration.

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.