Nginx 配置 php-fpm

nginx 配置文件示例:

server {
    listen       80;
    server_name  www.test.com;
    set $root_path  '/usr/local/project/項(xiàng)目index目錄';
    root $root_path;
    index index.php index.html index.htm;
    try_files $uri $uri/ @rewrite;
    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  /index.php;
        fastcgi_split_path_info    ^(.+\.php)(/.+)$;

        fastcgi_param PATH_INFO    $fastcgi_path_info;

        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include            fastcgi_params;

        client_max_body_size 30m;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {

           root $root_path;

    }

    location ~ /\.ht {
        deny  all;
    }
}

本地DNS配置

# vim /etc/hosts
127.0.0.1  www.test.com   //添加這一句

//查看是否配置成功
# ping www.test.com
PING www.test.com (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.073 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.074 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.076 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.065 ms
64 bytes from localhost (127.0.0.1): icmp_seq=6 ttl=64 time=0.073 ms
64 bytes from localhost (127.0.0.1): icmp_seq=7 ttl=64 time=0.080 ms
64 bytes from localhost (127.0.0.1): icmp_seq=8 ttl=64 time=0.118 ms
64 bytes from localhost (127.0.0.1): icmp_seq=9 ttl=64 time=0.078 ms
64 bytes from localhost (127.0.0.1): icmp_seq=10 ttl=64 time=0.073 ms
...

ok!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,534評論 19 139
  • 配置運(yùn)行Nginx服務(wù)器用戶(組) 用于配置運(yùn)行Nginx服務(wù)器用戶(組)的指令是user,其語法格式為: use...
    吃瓜的東閱讀 4,681評論 0 41
  • 第一章 Nginx簡介 Nginx是什么 沒有聽過Nginx?那么一定聽過它的“同行”Apache吧!Ngi...
    JokerW閱讀 33,018評論 24 1,002
  • 骨子里有著不服輸?shù)闹練?,可能平凡對于我來說就是一種奢侈品,消費(fèi)不起也享受不得,我只是在給自己找一個(gè)很努力的借口,逼...
    一抹淚痕一抹微笑閱讀 2,031評論 0 1
  • 一,<我的野蠻女友> 2001年 犬友在車站遇見一個(gè)喝醉女孩,幫助拉住。從此便認(rèn)識(shí),犬友無論多么想...
    一日光陰閱讀 460評論 0 0

友情鏈接更多精彩內(nèi)容