centosnginxphp
① centos7 怎么让nginx解析php
nginx是不能解析PHP的
需要使用php-fpm来解析PHP,nginx只是负责将用户请求转发给php进程,由PHP进程处理后将结果返回给nginx,最后nginx再讲请求返回给用户
nginx在这扮演一个网关服务器的角色
② centos6.5下配置nginx,nginx页面能出现,php测试页面显示空白!!!!!!
1、php5.3以后版本可以配置php-fpm.conf
listen = 127.0.0.1:9002
2、启动php-fpm服务器
/etc/init.d/php-fpm start
3、netstat -ntlp检查9001端口是否启动
4、配置nginx
server
{
listen 80;
access_log /data/logs/nginx/access.log;
root /data/www ;
index index.php index.html index.htm;
location / {
expires 1d;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
include fastcgi.conf;
}
}
③ CentOS Nginx+PHP-fpm下浏览器打开任何php页面都是file not found
把你那个 $document_root 换成直接的 /var/www 试试呢
类似下面的
location ~\.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/littlepig.cn/htdocs$fastcgi_script_name;
}
④ 请教一个问题 服务器 用的是 centos nginx php 总是报 502 Bad Gateway这个错误 如何解决
重启下php-fpm试试,或者修改fpm配置文件
/etc/php5/fpm/pool.d/www.conf
将
listen=/var/run/php5-fpm.sock
改为
listen=127.0.0.1:9000
试试。
⑤ linux centos nginx php-fpm 相加php扩展,才发现php.ini在phpinfo里没有
额...不用显示php.ini啊。告诉你放etc下就可以了
extension=redis.so
你确定这个so已经放在了php对应的目录下了么
extension=/path/to/extension/msql.so
写成这样的全路径试试
⑥ centos下nginx+php,几万并发,需要微调哪些参数实现高并发
在不考虑硬件,系统优化,WEB架构和程序优化,缓存,DB优化等,只考虑nginx,几个关键参数如下:
worker_processes 8;
worker_rlimit_nofile 60000;
events {
use epoll;
worker_connections 51200;
}
其实是很限的,对吧,不过nginx本身就是一个高并发web器,这些参数是根据实际情况调的。
⑦ centos+Nginx + PHP+mysql,请问我怎么开启rewrite
nginx不用开启rewrite,nginx的重写规则需要写在nginx的conf里面,下面是一些例子
rewrite重写需要写在location里面如
location/{
rewrite^/archiver/((fid|tid)-[w-]+.html)$/archiver/index.php?$1last;
rewrite^/forum-([0-9]+)-([0-9]+).html$/forumdisplay.php?fid=$1&page=$2last;
rewrite^/thread-([0-9]+)-([0-9]+)-([0-9]+).html$/viewthread.php?tid=$1&extra=page%3D$3&page=$2last;
rewrite^/space-(username|uid)-(.+).html$/space.php?$1=$2last;
rewrite^/tag-(.+).html$/tag.php?name=$1last;
}
完整的例子
server
{
listen80;
indexindex.htmlindex.htmindex.phpdefault.htmldefault.htmdefault.php;
root/data/wwwroot/yiqicms;
location/{
if(-f$request_filename/index.html){
rewrite(.*)$1/index.htmlbreak;
}
if(-f$request_filename/index.php){
rewrite(.*)$1/index.php;
}
rewrite^/article/(.+).html$/article.php?name=$1last;
rewrite^/proct/(.+).html/proct.php?name=$1last;
rewrite^/category/([^/]+)_([0-9]+)[/]?/category.php?name=$1&p=$2last;
rewrite^/category/([^/_]+)[/]?/category.php?name=$1last;
rewrite^/catalog/([^/]+)[/]?/catalog.php?type=$1last;
rewrite^/comment.html$/comment.phplast;
rewrite^/sitemap.xml$/sitemap.phplast;
rewrite^/a_(.+).html$/article.php?name=$1last;
rewrite^/p_(.+).html/proct.php?name=$1last;
rewrite^/c_([^/]+)_([0-9]+)[/]?/category.php?name=$1&p=$2last;
rewrite^/c_([^/_]+)[/]?/category.php?name=$1last;
error_page404/404.htm;
}
location~.*.(php|php5)?$
{
try_files$uri=404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_indexindex.php;
includefcgi.conf;
}
location~.*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires30d;
}
location~.*.(js|css)?$
{
expires30d;
}
}
⑧ nginx不解析php,访问php文件弹出直接下载该文件 系统是centos7
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
⑨ 为什么centos7下nginx的php怎么开启报错
首先要编辑php配置文件:
vi /etc/php.ini
error_reporting = E_ERROR
display_errors = On
因为我开启了php-fpm。所以,还要编辑 php-fpm.conf文件,把php_flag[display_errors]设为on:
vi php-fpm.conf
php_flag[display_errors] = on
这样在开发的时候就可以在浏览器中显示php出现的错误了,非常方便。
⑩ centos nginx 产看php 安装了哪些版本
貌似在编辑时,不太能直接看到效果。你自己在本地搭建一个PHP可运行的环境。代码写完了,你直接运行一下不就可以了?倒是HTML可以边写边看,DW就可以实现。至于写PHP,我个人用DW,效果还不错。也有很多人用EDIDPLUS,个人习惯不同,习惯用什么就用什么。eclipse,这个软件也很NB,在编写状态下,可以检查PHP的语法错误。也算比较方便。
楼主觉得不清楚,可以自己去后盾人学习,这样求别人不如靠自己哦.