Chinaunix首页 | 论坛 | 博客
  • 博客访问: 105635
  • 博文数量: 36
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 330
  • 用 户 组: 普通用户
  • 注册时间: 2014-08-18 23:16
文章分类
文章存档

2016年(7)

2015年(20)

2014年(9)

我的朋友

分类: 服务器与存储

2015-05-28 02:09:56

 安装php(这里主要讲nginx配置启动php,以cgi运行php)

 nginx配置文件是conf文件夹里的nginx.conf

 1.修改大概第43~45行之间的

         location /{
            root   html;
            index  index.html index.htm;}
 修改网站文件的路径,以及添加index.php的默认页。
 
         location / {
             root   D:/wnmp/nginx-1.5.8/html;
             index  index.html index.htm inde.php;
          }

2.支持php的设置

  修改大概在第63-71行的
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1: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;
        #}
  先将前面的“#”去掉。再把“/scripts”改为“$document_root”,这里的“$document_root”就是指前面“root”所指的站点路径,这是改完后的:
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root          html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #    include        fastcgi_params;
        #}


3.php安装目录下修改php.ini-development文件,将文件名修改为php.ini,打开php配置文件php.ini,保存即可。

   搜索“extension_dir”,找到: e;xtension_dir = "ext" 先去前面的分号再改为 extension_dir = "d:\wnmp\php\ext"

   搜索“date.timezone”,找到:;date.timezone = 先去前面的分号再改为 date.timezone = Asia/Shanghai

   搜索“enable_dl”,找到:enable_dl = Off 改为 enable_dl = On

   搜索“cgi.force_redirect” ;cgi.force_redirect = 1 先去前面的分号再改为 cgi.force_redirect = 0

   搜索“fastcgi.impersonate”,找到: ;fastcgi.impersonate = 1 去掉前面的分号

   搜索“cgi.rfc2616_headers”,找到:;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1

   搜索“php_mysql”,找到:”extension=php_mysql.dll和extension=php_mysqli.dll  去掉前面的“;”extension=php_mysql.dll和extension=php_mysqli.dll   (支持MYSQL数据库)

   其他的配置请按照自己的需求更改。

   第三部分试运行以及编辑运行配置文件

 d:\wnmp\php-5.5.7>php-cgi.exe -b 127.0.0.1:9000-c php.ini

   重新运行nginx.exe。

 C:\wnmp\nginx-1.5.8\html下新建一个phpinfo.php,访问或者

 --------------------------------------------------------------------------------------------------------------------

开启php-cgi和nginx.exe,保存为start.bat

@echo off echo Starting PHP FastCGI... C:\wnmp\nginx\RunHiddenConsole.exe C:\wnmp\PHP\php-cgi.exe -b 127.0.0.1:9000-c D:\PHP\php.ini echo Starting nginx... C:\wnmp\nginx\RunHiddenConsole.exe D:/nginx/nginx.exe -p D:/nginx

停止php-cgi和nginx.exe,保存为stop.bat

@echo off echo Stopping nginx... taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul exit



阅读(1370) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~