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的語法錯誤。也算比較方便。
樓主覺得不清楚,可以自己去後盾人學習,這樣求別人不如靠自己哦.