nginx 基本命令:
查看Nginx的版本号:nginx -V
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload
查看windows任务管理器下Nginx的进程命令:tasklist /fi "imagename eq nginx.exe"
1、下载nginx自然不必说了,自己百度吧
2、解压下载文件,cmd命令寻找nginx安装文件,执行start nginx
3、localhost
4、安装php(nginx配置启动php,以cgi运行php)
nginx配置文件是conf文件夹里的nginx.conf
查找文件字符
location /{
root html;
index index.html index.htm;
}
修改为:
location / {
root D:/wnmp/nginx-1.5.8/html; #网站根目录
index index.html index.htm inde.php; #添加index.php的默认页。
}
# 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;
#}
先将前面的“#”去掉,同样将root html;改为root C:/wnmp/nginx-1.5.8/html;。再把“/scripts”改为“$document_root”,这里的 “$document_root”就是指前面“root”所指的站点路径,这是改完后的:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 #
#location ~ \.php$ {
# root C:/wnmp/nginx-1.5.8/html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
5、配置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数据库)
其他的配置请按照自己的需求更改。
6、
试运行以及编辑运行配置文件
C:\wnmp\php-5.5.7-nts-Win32-VC11-x86>php-cgi.exe -b 127.0.0.1:9000-c C:\wnmp\php-5.5.7-nts-Win32-VC11-x86\php.ini
重新运行nginx.exe。
C:\wnmp\nginx-1.5.8\html下新建一个phpinfo.php,
<?php phpinfo(); ?>
下载一个RunHiddenConsole.exe (百度)
开启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和nginx进程,如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
start.bat和stop.bat要和RunHiddenConsole.exe放于同一个目录
来源:https://www.cnblogs.com/ysp123/p/5715899.html