国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

nginx簡(jiǎn)單配置多個(gè)php服務(wù)實(shí)例教程

瀏覽:107日期:2022-06-06 17:47:36
目錄
  • 摘要:
  • 系統(tǒng):mac、linux
  • 配置多個(gè)服務(wù):
  • 總結(jié)

nginx簡(jiǎn)單配置php服務(wù)(多個(gè))

摘要:

大部分網(wǎng)站開(kāi)發(fā)語(yǔ)言都要運(yùn)行在服務(wù)器,比如主流的nginx、apache等等,部署服務(wù)器環(huán)境對(duì)于大部分人來(lái)說(shuō)是比較陌生和復(fù)雜的,其實(shí)搞懂了之后是很簡(jiǎn)單易用的。今天就記錄下部署php+nginx。

系統(tǒng):mac、linux

1、安裝好php和nginx程序,并運(yùn)行

2、找到nginx.conf文件,默認(rèn)在/etc/nginx目錄下,如果找不到用一下命令查詢

sudo find / -name nginx.conf

3、修改nginx.conf文件

默認(rèn)的nginx.conf配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pidlogs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  "$remote_addr - $remote_user [$time_local] "$request" "
    #  "$status $body_bytes_sent "$http_referer" "
    #  ""$http_user_agent" "$http_x_forwarded_for"";

    #access_log  logs/access.log  main;

    sendfileon;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
listen       80;
server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
    root   html;
    index  index.html index.htm;
}

#error_page  404      /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# 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  /scripts$fastcgi_script_name;
#    includefastcgi_params;
#}

# deny access to .htaccess files, if Apache"s document root
# concurs with nginx"s one
#
#location ~ /\.ht {
#    deny  all;
#}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #root   html;
    #index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #root   html;
    #index  index.html index.htm;
    #    }
    #}
    include servers/*;
}

把server下的這段#號(hào)去掉并修改即可,將 PHP 腳本傳遞給在 127.0.0.1:9000 上偵聽(tīng)的 FastCGI 服務(wù)器

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    includefastcgi_params;
}

訪問(wèn) localhost

參數(shù)參考:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;#腳本文件請(qǐng)求的路徑
fastcgi_param  QUERY_STRING       $query_string; #請(qǐng)求的參數(shù);如?app=123
fastcgi_param  REQUEST_METHOD     $request_method; #請(qǐng)求的動(dòng)作(GET,POST)
fastcgi_param  CONTENT_TYPE       $content_type; #請(qǐng)求頭中的Content-Type字段
fastcgi_param  CONTENT_LENGTH     $content_length; #請(qǐng)求頭中的Content-length字段。
 
fastcgi_param  SCRIPT_NAME$fastcgi_script_name; #腳本名稱 
fastcgi_param  REQUEST_URI$request_uri; #請(qǐng)求的地址不帶參數(shù)
fastcgi_param  DOCUMENT_URI       $document_uri; #與$uri相同。 
fastcgi_param  DOCUMENT_ROOT      $document_root; #網(wǎng)站的根目錄。在server配置中root指令中指定的值 
fastcgi_param  SERVER_PROTOCOL    $server_protocol; #請(qǐng)求使用的協(xié)議,通常是HTTP/1.0或HTTP/1.1。  
 
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;#cgi 版本
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;#nginx 版本號(hào),可修改、隱藏
 
fastcgi_param  REMOTE_ADDR$remote_addr; #客戶端IP
fastcgi_param  REMOTE_PORT$remote_port; #客戶端端口
fastcgi_param  SERVER_ADDR$server_addr; #服務(wù)器IP地址
fastcgi_param  SERVER_PORT$server_port; #服務(wù)器端口
fastcgi_param  SERVER_NAME$server_name; #服務(wù)器名,域名在server配置中指定的server_name

配置多個(gè)服務(wù):

nginx.conf文件有一行

include servers/*;

代表會(huì)讀取servers文件夾下的所有配置文件,沒(méi)有可以自己加上,并創(chuàng)建文件夾,servers文件夾下創(chuàng)建一個(gè)站點(diǎn)配置文件site1.conf。

server {
    listen       80;#端口
    server_name  site1.com;#你的站點(diǎn)域名/ip
    root /data/site1/public; #你的站點(diǎn)目錄,絕對(duì)路徑即可
    index index.php index.html index.htm;

    #charset koi8-r;
    #access_log  logs/host.access.log  main;
    location / {
try_files $uri $uri/ /index.php?$query_string;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
root   html;
    }
    location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
includefastcgi_params;
    }
}

總結(jié)

到此這篇關(guān)于nginx簡(jiǎn)單配置多個(gè)php服務(wù)的文章就介紹到這了,更多相關(guān)nginx配置php服務(wù)內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: PHP
主站蜘蛛池模板: 日本免费一二区视频 | 免费看国产精品久久久久 | 美女张开腿让男生桶出水 | 国产精品国产亚洲精品不卡 | 一区二区在线播放福利视频 | 人碰人操| 国产亚洲精品一区二区在线播放 | 成人国产一区二区三区精品 | 欧美亚洲国产精品久久久久 | 欧洲免费无线码二区5 | 欧美日韩亚洲国产 | 欧美精品久久久久久久久大尺度 | 男女猛烈无遮掩免费视频 | 成人男女网18免费91 | 国产伦码精品一区二区 | 玖玖啪 | 欧美日韩国产高清一区二区三区 | 一级日韩| 欧美午夜伦y4480私人影院 | 国产亚洲精品日韩已满十八 | 欧美a大片 | 美女视频黄在线观看 | 美女视频黄的免费看网站 | 一级爱爱片一级毛片-一毛 一级爱做片免费观看久久 一级白嫩美女毛片免费 | 国产高清免费影视在线观看 | 男人和女人的做刺激性视频 | aaaa级毛片 | 男女性高爱潮免费的国产 | 成人网在线视频 | 三级欧美在线 | 日韩在线手机看片免费看 | 综合自拍 | 日本精品一在线观看视频 | 久久精品国产亚洲7777小说 | 手机看片精品国产福利盒子 | 香蕉视频黄色在线观看 | 国产精品久久国产三级国电话系列 | 自拍偷拍视频在线观看 | 国产精自产拍久久久久久 | 国产主播大尺度精品福利 | 色哟哟国产成人精品 |