2014-07-01 36 views
1

我想設置nginx服務器來使用PHP和MySQL。要做到這一點,我有:該頁面當前不可用

  1. 下載nginx的文件,解壓縮它(C:/nginx/
  2. 下載PHP二進制文件,並把它們放在裏面C:/nginx/php/
  3. 更改C:/nginx/conf/nginx.conf到

worker_processes 1; 

#error_log logs/error.log; 
#error_log logs/error.log notice; 
#error_log logs/error.log info; 

#pid  logs/nginx.pid; 


events { 
    worker_connections 1024; 
} 


http { 
    include  mime.types; 
    default_type application/octet-stream; 

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
    #     '$status $body_bytes_sent "$http_referer" ' 
    #     '"$http_user_agent" "$http_x_forwarded_for"'; 

    #access_log logs/access.log main; 

    sendfile  on; 
    #tcp_nopush  on; 

    #keepalive_timeout 0; 
    keepalive_timeout 65; 

    #gzip on; 

    server { 
     listen  80; 
     server_name localhost; 

     #charset koi8-r; 

     #access_log logs/host.access.log main; 

     location/{ 
      root html; 
      index index.php index.html index.htm; 
     } 

     #error_page 404    /404.html; 

     # redirect server error pages to the static page /50x.html 
     # 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root html; 
     } 

     # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
     # 
     location ~ \.php$ { 
      proxy_pass http://127.0.0.1; 
     } 

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

     # deny access to .htaccess files, if Apache's document root 
     # concurs with nginx's one 
     # 
     #location ~ /\.ht { 
     # deny all; 
     #} 
    } 


    # another virtual host using mix of IP-, name-, and port-based configuration 
    # 
    #server { 
    # listen  8000; 
    # listen  somename:8080; 
    # server_name somename alias another.alias; 

    # location/{ 
    #  root html; 
    #  index index.html index.htm; 
    # } 
    #} 


    # HTTPS server 
    # 
    #server { 
    # listen  443 ssl; 
    # server_name localhost; 

    # ssl_certificate  cert.pem; 
    # ssl_certificate_key cert.key; 

    # ssl_session_cache shared:SSL:1m; 
    # ssl_session_timeout 5m; 

    # ssl_ciphers HIGH:!aNULL:!MD5; 
    # ssl_prefer_server_ciphers on; 

    # location/{ 
    #  root html; 
    #  index index.html index.htm; 
    # } 
    #} 

} 

不幸的是,我不能得到的文件到.PHP工作。試圖運行一個只顯示「對不起,您正在尋找的頁面當前不可用。」信息。

我有乾淨的環境,所以我只有nginx和php ...這裏有什麼不對?

+0

您需要安裝php-fpm以在nginx中運行php。你也不需要改變這一行 –

回答

0

您需要安裝php-fpm以在nginx中運行php。您還需要牛逼此行

fastcgi_pass 127.0.0.1:9000; 

改變這一

fastcgi_pass unix:/var/run/php5-fpm.sock; 

更改此UNIX:/var/run/php5-fpm.sock;到php-fpm sock文件路徑。

+0

我沒有提到我在Windows上運行它,但是謝謝,我會試試看。 – khernik