参考链接:https://www.cnblogs.com/wuzhenbo/p/3493518.html
nginx 配置文件
修改大概第43~45行之间的
#user nobody;
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 81;
server_name localhost;
charset "utf-8";
#access_log logs/host.access.log main;
location / {
root "E:/gr_work_code/php_code";
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 "E:/gr_work_code/php_code";
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$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;
# }
#}
}
2.php 配置
打开php配置文件php.ini
搜索“extension_dir”,找到: e;xtension_dir = “ext” 先去前面的分号再改为 extension_dir = “C:\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数据库)
在php的目录下运行下面命令,开启php端口监听。
php-cgi.exe -b 127.0.0.1:9000 -c C:\wnmp\php-5.5.7-nts-Win32-VC11-x86\php.ini
启动nginx,输入localhost:81/index.php