WIN 下nginx + php7 配置

下載PHP7 javascript

下載nginxphp

(有可能遇到缺乏dll文件,在運行php 的exe時候)下載地址:https://git.oschina.net/bingoPureLife/Some-Files-very-useful/raw/master/vcruntime140.rarcss

讓nginx工做起來:html

cd 到nginx根目錄 start nginx 可是奇怪的是 nginx -s stop 並不能停掉nginxjava

我選擇了殺進程nginx

tasklist /fi "imagename eq nginx.exe" git

找出相關的進程 一一殺掉 taskkill /f /pid xxx || taskkill /f /im nginx.exeapp

 

修改一下配置文件讓咱們的nginx可以處理PHP請求;實際上咱們的nginx 不能解釋PHP的atom

error_log  logs/error.log  error ;
pid logs/nginx.pid;
worker_processes  auto;
worker_rlimit_nofile 51200;

events {
    worker_connections  51200;
}


http {
    client_body_buffer_size 32k;
    client_header_buffer_size 2k;
    client_max_body_size 2m;
    default_type application/octet-stream;
    log_not_found off;
    server_tokens off;
    include       mime.types;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
    gzip_vary on;
    #error_page   500 502 503 504  /50x.html; 
    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';

    server {
        listen 80 default_server;
        server_name localhost;
        root apps/www/;
        index index.php index.html index.htm;

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PHP_VALUE        open_basedir=$document_root:/tmp/:/proc/;
            include        fastcgi_params;
        }

    }

    include vhost/*.conf;
    
}

 

而後發現結果處理PHP 請求失敗了。fastcgi_pass 127.0.0.1:9000; 從這一句看,咱們nginx 直接會把php請求扔這裏。而後再php那邊調用php解釋器spa

既然咱們PHP 請求502錯誤;timeout; 

看看咱們的9000端口正常不。

實際上nginx 經過fastcgi 和PHP之間走的是TCP 因此判定;咱們的fastcgi 並無在工做;

(把php根目錄下的php.ini-development 改爲ini文件)

啓動fastcgi

在根目錄 php-cgi.exe -b 127.0.0.1:9000-c php.ini

咱們在看看端口狀況

 

相關文章
相關標籤/搜索