linux下怎么让nginx支持php

2025-03-04 02:16:15
推荐回答(3个)
回答1:

安装 PHP-FPM

1. 开始安装 Nginx 和 PHP-FPM 之前,你可能需要卸载系统中以前安装的 Apache 和 PHP。

1
yum erase php*
2
or
3
yum remove httpd* php* #这个命令是删除不干净的
4
yum remove php-cli php-common php #删除
重新安装 PHP:

1
yum --skip-broken install php53
2. CentOS 6.2/6.1/6/5.8 下安装Remi源:

1
## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
2
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
3

4
## CentOS 5 and Red Hat (RHEL) 5 ##
5
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
3. 安装 PHP-FPM:

1
yum --enablerepo=remi,remi-test install nginx php php-fpm php-common
2
or
3
yum --enablerepo=remi install php53 php-fpm
4. 安装完毕之后启动 PHP-FPM:

1
/etc/init.d/php-fpm start
2
## OR ##
3
service php-fpm start
5. 设置Nginx & PHP-FPM开机自启动:

1
chkconfig --add nginx
2
chkconfig --levels 235 nginx on
3
chkconfig --add php-fpm

回答2:

  1. nginx本身就是php的发布软件,自己就支持php的

  2. 一定要在nginx期待的情况下使用,所有的php项目放在配置的项目文件夹


回答3:

安装个就可以了