Nginx 配置 php-fpm

nginx 配置文件示例:

server {
    listen       80;
    server_name  www.test.com;
    set $root_path  '/usr/local/project/项目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!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,027评论 19 139
  • 配置运行Nginx服务器用户(组) 用于配置运行Nginx服务器用户(组)的指令是user,其语法格式为: use...
    吃瓜的东阅读 4,559评论 0 41
  • 第一章 Nginx简介 Nginx是什么 没有听过Nginx?那么一定听过它的“同行”Apache吧!Ngi...
    JokerW阅读 32,819评论 24 1,002
  • 骨子里有着不服输的志气,可能平凡对于我来说就是一种奢侈品,消费不起也享受不得,我只是在给自己找一个很努力的借口,逼...
    一抹泪痕一抹微笑阅读 1,955评论 0 1
  • 一,<我的野蛮女友> 2001年 犬友在车站遇见一个喝醉女孩,帮助拉住。从此便认识,犬友无论多么想...
    一日光阴阅读 340评论 0 0