[英]how to install php with nginx
我是与Web服务器相关的所有事物的新手。 到目前为止,我使用的是Apache。 但是我想尝试一下nginx。 因此,我决定将其与PHP一起安装。 这是我遵循的步骤(我提到我使用Windows 7):
我使用以下代码创建了start.bat文件(在nginx文件夹中):
@ECHO OFF启动C:\\ nginx \\ nginx.exe启动C:\\ nginx \\ php \\ php-cgi.exe -b 127.0.0.1:9000 -c C:\\ nginx \\ php \\ php.ini-开发ping 127.0.0.1 -n 1> NULL echo启动nginx echo。 echo .. echo ... ping 127.0.0.1> NUL EXIT
我使用以下代码创建了stop.bat文件(在nginx文件夹中):
@ECHO OFF taskkill / f / IM nginx.exe taskkill / f / IM php-cgi.exe退出
我编辑了nginx / conf / nginx.conf文件,如下所示:
位置〜.php $ {根html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME C:/ nginx / html / $ fastcgi_script_name; 包括fastcgi_params; }
我在start.bat的帮助下启动了Nginx
我用一个简单的代码在nginx / html /目录中创建了一个新的php文件(test.php):
但是,当我导航到127.0.0.1/test.php时,它花费了很长的时间(一分钟),之后,我得到了以下错误:
------------------------------------------------------
An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.
If you are the system administrator of this resource then you should check the error log for details.
Faithfully yours, nginx.
-----------------------------------------------------
如果单击error log
链接,则会显示以下屏幕:
有什么办法吗? 谢谢。
下载完两个设置后,将它们解压缩到C://驱动器中。
将解压php文件夹放在nginx文件夹中。
现在,按照本视频中的步骤进行操作。
要在nginx中配置PHP,我们需要在nginx.conf文件中进行一些更改。
删除nginx.conf文件中的旧代码,将其粘贴到nginx.conf中的代码下方。
这是代码:
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME C:/nginx/html/$fastcgi_script_name;
}
要启动nginx和php,请使用以下批处理代码:
@ECHO OFF
start C:\nginx\nginx.exe
start C:\nginx\php\php-cgi.exe -b 127.0.0.1:9000 -c C:\nginx\php\php.ini
ping 127.0.0.1 -n 1>NUL
echo Starting nginx
echo .
echo ..
echo ...
ping 127.0.0.1 >NUL
EXIT
要停止nginx和php,请使用以下批处理代码。
@ECHO OFF
taskkill /f /IM nginx.exe
taskkill /f /IM php-cgi.exe
Exit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.