zoukankan      html  css  js  c++  java
  • 如何改变服务器的本地域名来访问本地服务器 而不用localhost或者127.0.0.1来访问

     1.

    vim nginx.conf

    如下:

    server {
                    listen       80;
                    server_name pma;
                    index index.php;
                    root  /home/XXXXX;
                    location ~ .*.(php|php5)?$
                            {
                                    try_files $uri =404;
                                    fastcgi_pass  unix:/tmp/php-cgi.sock;
                                    fastcgi_index index.php;
                                    include fcgi.conf;
                            }


    }

    server
            {
                    listen       80;
                    server_name   pmb;
                    index index.php;
                    root  /home/wwwroot/default;

                    #location ~ .*.(php|php5)?$
                    #       {
                    #               try_files $uri =404;
                    #               fastcgi_pass  unix:/tmp/php-cgi.sock;
                    #               fastcgi_index index.php;
                    #               include fcgi.conf;
                    #       }

                    #location /status {
                    #       stub_status on;
                    #       access_log   off;
                    #}

                    location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
                            {
                                    expires      30d;
                            }

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

                            }



                    #if (-f $request_filename) {
                    #        break;
                    #}

     rewrite "^/work/(.*)$" /work/index.php/$1 last;
    ………………………………………………………………


    2.

    vim /etc/hosts

    添加下面:

    127.0.0.1       pma
    127.0.0.1       pmb


    3. /etc/init.d/nginx restart

    这样就可以通过http://pmb/XXX/XXX/XXX来访问了。

  • 相关阅读:
    【服务后端】Django 返回的QuerySet序列化
    【服务后端】Django的多表数据查询
    【微信开发】2、全局Token获取
    【微信开发】1、服务器响应,与微信服务器握手
    【服务后端】Python序列化对象为Json方法
    【服务后端】Django对比查询结果中的id时报错'dict' object has no attribute 'id'
    【网页前端】WeX5架构下,WinDialog子窗口1传递参数给主窗口关闭,再弹出子窗口2失败
    【系统运维】CentOS系统MySql,Tomcat和Django自启动
    【网络开发】WeX5的Ajax和Django服务器json接口对接跨域问题解决
    21.1
  • 原文地址:https://www.cnblogs.com/hackerl/p/3232805.html
Copyright © 2011-2022 走看看