linux服务器下LNMP安装与配置方法

2019-10-14 22:24:08丽君

            root   html;
        }
}
server {
        listen       80;
        server_name  www.sohu.com;
        access_log  logs/sohu.access.log  main;
        location / {
            root   /web/sohu;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        }

例2:静态index.html跳转到动态index.php文件
cd  /web/sina/
vi  index.php
       <?
        print_r ($_GET);
?>
       Vi  nginx.conf
           server {
        listen       80;
        server_name  www.sina.com;
        access_log  logs/sina.access.log  main;
        location / {
            root   /web/sina;
            index  index.html index.htm;
            rewrite  ^/index(d+).html  /index.php?id=$1  last;
# ^/ 以/开头。d+ 多个数字。()第一个变量。     /index.php?id=$1 把第一个变量赋予id变量,传入index.php文件
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ .php$ {
            root           /web/sina;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;