nginx默认是不能解析PHP的,要解析PHP需要修改nginx的配置文件。 打开nginx.conf, 找到location / 修改如下: location / { root /var/www; index index.php index.html index.htm; } 找到location ~ .php$,修改如下: location ~ .php$ { root /var/www;
nginx默认是不能解析PHP的,要解析PHP需要修改nginx的配置文件。
打开nginx.conf,
找到location / 修改如下:
location / {
root /var/www;
index index.php index.html index.htm;
}
找到location ~ .php$,修改如下:
location ~ .php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
root:设置PHP脚本的根目录
fastcgi_pass:处理PHP脚本的端口,这里监听9001
fastcgi_index :索引文件
fastcgi_param:php脚本路径
设置完之后,还需要配置php-fpm.conf,进入你的php安装目录下的etc文件夹,将php-fpm.conf.default重命名为php-fpm.conf,双击打开,修改listen为9001。
启动终端,cd进入php安装目录的sbin文件夹,使用./php-fpm命令启动fpm,如果启动报错,打开php-fpm.conf,去掉如下语句前的注视,然后重启php-fpm
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
配置nginx和php-fpm开机自启动:
打开/etc/rc.local,在末尾添加
ulimit -SHn 65535
/var/web/php/sbin/php-fpm
/var/web/nginx/sbin/nginx
保存文件,重启。
注意把/var/web/php和/var/web/nginx修改成你自己的php/nginx安装目录。
在var/www目录下新建index.php,写入代码:
phpinfo();
?>
访问:http://localhost,出现php配置信息界面,大功告成!
PS:手动启动nginx,打开终端,cd进入nginx的sbin目录,使用./nginx命令启动nginx

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
