linux lnmp的nginx配置文件实例

静态页面的配置

server {
        listen       90;
        server_name  127.0.0.1;
        location / {
            root   /home/wwwroot/default;
            index  index.html index.htm;
        }
   }

#php文件的配置
listen 80 ; 代表的是端口,若是其他端口,可以把80换成你想要的端口
server_name 是访问名称,可以填域名或者IP,一开始是server_name _; 这个低杠是默认本服务器的IP
#index 是访问的默认文件,一般不需要修改
#root 是配置网站的项目绝对路径

伪静态

    if (!-e $request_filename) {
     rewrite  ^(.*)$  /index.php?s=/$1  last;
      break;
    }

这个是TP的nginx伪静态,lnmp安装好之后是没有的,这个一定要加

nginx.conf

server
    {
        listen 80;
       # listen [::]:80 default_server ipv6only=on;
        server_name 127.0.0.1;
        index index.html index.htm index.php;
        root  /home/wwwroot/xiangmu/src/public;
        #error_page   404   /404.html;
        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
        if (!-e $request_filename) {
         rewrite  ^(.*)$  /index.php?s=/$1  last;
          break;
        }
        include enable-php.conf;
        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }
        access_log  /home/wwwlogs/access.log;
    }
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值