Home > Backend Development > PHP Tutorial > win7+nginx+php筹建

win7+nginx+php筹建

WBOY
Release: 2016-06-13 12:40:48
Original
804 people have browsed it

win7+nginx+php搭建

?

操作系统:window7??? php5.4.17???? nginx1.5.2

?

?下载

  • 下载php,地址:http://www.php.net/downloads.php如图


  • 先在E盘创建一个名叫“wnmp”的文件夹,然后把PHP解压到改文件下。

  • 下载nginx,地址:http://nginx.org/en/download.html如图



?

?

  • 在wnmp文件夹中创建名为“nginx”文件夹,把nginx解压到改文件夹下。

配置?

  • 进入php文件夹,将“php.ini-development”修改为php.ini
  • 打开php.ini文件,对一下内容进行修改
  • extension_dir = "ext"
    date.timezone = Asia/ChongQing
    Copy after login
    ?

因为nginx需要cgi方式的php,所以还需要更改一下几处内容

enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
Copy after login

?到这里PHP配置告一段落,接着配置nginx。

?

  • 先启动nginx,用DOS进入nginx路径,用一下命令启动nginx
  • nginx -s reload //重启Nginx
    nginx -s stop //暂停
    nginx -s quit //退出nginx
    start nginx //启动
    Copy after login
    ?然后在浏览器的地址栏中输入127.0.0.1出现一下界面,说明nginx启动正常

  • nginx默认访问的是E:\wnmp\nginx\html\index.html下面的index.php文件。
  • 修改nginx.conf(E:\wnmp\nginx\conf\nginx.conf)文件,进行网站的配置
  • events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        server {
        listen  80;
        server_name  localhost; #本地IP
        root   E:/wnmp/www; #存放网站的根目录
        location / {
                index  index.php index.html index.htm; #添加index.php。
                #autoindex on;#如果文件不存在列出目录结构;
            }
             location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000; #fastcgi及监听的端口与php的cgi启动时要一致
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
        }
    }
    Copy after login
    ?
    ?到这里所以的配置完成。

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template