nginx 配置php

安装php

yum install php
 
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

 

添加nginx 默认主页index.php 

vim /etc/nginx/conf.d/default.conf 

 

location / {

        root   /usr/share/nginx/html;   //改路径

        index  index.html index.htm index.php;  //index.php

    }

 

配置nginx支持php

vim /etc/nginx/conf.d/default.conf 

 

# 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  /usr/share/nginx/html$fastcgi_script_name;    //改路径

        include        fastcgi_params;

    }

 

配置php-fpm

vim /etc/php-fpm.d/www.conf

 

; Unix user/group of processes

; Note: The user is mandatory. If the group is not set, the default user's group

;       will be used.

; RPM: apache Choosed to be able to access some dir as httpd

user = nginx

; RPM: Keep a group allowed to write in log dir.

group = nginx

 

chkconfig php-fpm on    #设置php-fpm自启动

chkconfig mysqld on     #设置mysqld自启动

service nginx restart   #重新启动nginx

service php-fpm start   #启动php-fpm

service mysqld start    #启动mysqld

posted @   zhaocundang  阅读(310)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示