当前位置:Gxlcms > PHP教程 > 配置?

配置?

时间:2021-07-01 10:21:17 帮助过:3人阅读

win7+nginx+php搭建

?

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

?

?下载

  • 下载php,地址:http://www.php.com/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
    ?

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

enable_dl = Oncgi.force_redirect = 0cgi.fix_pathinfo=1fastcgi.impersonate = 1cgi.rfc2616_headers = 1

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

?

  • 先启动nginx,用DOS进入nginx路径,用一下命令启动nginx
  • nginx -s reload //重启Nginxnginx -s stop //暂停nginx -s quit //退出nginxstart nginx //启动
    ?然后在浏览器的地址栏中输入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;        }    }}
    ?
    ?到这里所以的配置完成。

?

人气教程排行