美文网首页
跳转配置

跳转配置

作者: 白纸糊 | 来源:发表于2019-04-01 14:41 被阅读0次

假设你想在Linux Nginx中用不同的域名访问不同的目录,这时就要配置多个vhost,具体配置如下,假设网站根目录设定在/var/www/

1、在/var/www/下新建两个目录

 /var/www/ushark.net
 /var/www/ushark.wang</pre>

2、编辑/etc/nginx/nginx.conf

http {
    include /etc/nginx/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 /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout 65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;   #主要是加入此行,如有则忽略
    }

3、在/etc/nginx/conf.d下新建两个conf文件,

/etc/nginx/conf.d/ushark.net.conf 
/etc/nginx/conf.d/ushark.wang.conf

4、复制如下配置信息到两个文件中,只要修改红色部分内容  !!! server_name与root保持一致即目录和域名一一对应 !!!

server {
    listen 80;
    server_name   [www.ushark.net](http://www.ushark.net/);

    #charset koi8-r;
    #access_log /var/log/nginx/host.access.log  main;
    root /var/www/ushark.net/; if (!-e $request_filename){    # rewrite可根据网站需要增删
            rewrite ^/(.*) /index.php last;  
    }  

    location / {
        index  index.php 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 /var/www/ushark.net/;
    }

    # 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$ {
        fastcgi_index   index.php;
        fastcgi_pass 127.0.0.1:9000;
        include           fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }

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

5、重启Nginx

systemctl restart nginx

6、 编辑/etc/hosts  !!! 核心步骤 !!!

[root@bogon ~]# vi 127.0.0.1 localhost.localdomain localhost
   ::1 localhost6.localdomain6 localhost6 
   127.0.0.1        www.ushark.net
   127.0.0.1        www.ushark.wang

7、设置成功

相关文章

  • angular路由传递参数

    路由配置 跳转前页面 跳转后页面

  • Flutter路由跳转

    路由配置 定义路由配置信息 在MaterialApp的routes属性中指向设置的路由配置 跳转 1-跳转至配置的...

  • Vue 动态设置路由Meta title 名称

    路由配置 路由跳转 或路由配置 路由跳转 都可以,看着用。随堂笔记防遗忘!

  • iOS:APP跳转

    1: Universal Links 后台配置跳转包名 跳转并且可以拿到回调 2: URL Scheme 本地配置...

  • 动态路由理解

    一、通过配置动态路由进行页面跳转同时进行参数传递 1、配置路由 2、跳转设置 ----------》注意这种方式...

  • 跳转配置

    假设你想在Linux Nginx中用不同的域名访问不同的目录,这时就要配置多个vhost,具体配置如下,假设网站根...

  • 微信小程序的跳转方式

    微信小程序有5种跳转方式 switchTab这种跳转只能跳转到 tabBar 配置的页面 navigateBack...

  • angualr(二) 路由之angualr-router

    创建项目 路由的基本使用 路由对象图示 路由基本配置 路由通配符配置 HTML里面跳转链接 在js里面跳转路由 路...

  • vue路由传值

    第一种:props配置 组件内定义: 路由映射配置,开启props:true : 跳转传参: 1、标签跳转 2.函...

  • 路由工具ARouter和CC对比:Arouter

    ARouter 配置 配置依赖 引用gradle插件 配置moduleName和debug信息 使用 初始化 跳转...

网友评论

      本文标题:跳转配置

      本文链接:https://www.haomeiwen.com/subject/fsdvbqtx.html