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之验证码
    无法显示SQL Server Management Studio Express解决办法
    程序员常用不常见很难得的地址大全转
    调用ip138的页面获取IP地址
    VS 2010无法创建项目提示写入项目文件时出错 没有注册类别
    webapi token、参数签名是如何生成的(转载)
    尝试asp.net mvc 基于controller action 方式权限控制方案可行性(转载)
    委托学习
    Webapi上传数据(XML)敏感字符解决方案
    redis 学习
  • 原文地址:https://www.cnblogs.com/hackerl/p/3232805.html
Copyright © 2011-2022 走看看