如何在linux下配置nginx支持php

如何在linux下配置nginx支持php,第1张

需要。

如果是nginx+php配置,也可以通过查找php执行路径

ps

aux

|

grep

php

如,路径为

/usr/local/nginx/sbin/php-fpm

然后执行以下命令

/usr/local/nginx/sbin/php-fpm

-i

|

grep

“Loaded

Configuration

File”

即可看到php加载的配置文件

直接安装上PHP程序,然后在nginx中配置php文件使用php程序执行就可以了。两者之间是没有影响的,也就是说java程序和PHP程序是一样的。你java怎么配置的,PHP就可以怎么配置。

安装 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


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8678183.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-19
下一篇2023-04-19

发表评论

登录后才能评论

评论列表(0条)

    保存