zoukankan      html  css  js  c++  java
  • 在vmware虚拟机中如何配置本地域名并实现访问

    在vmware虚拟机中配置本地域名并实现访问,分为三步:

    一、编辑本机中的hosts文件

    1、打开我的电脑,进入本地磁盘C:WindowsSystem32driversetc,如图:

    2、找到hosts文件并用记事本打开,添加域名以及ip地址,如图:

    二、编辑虚拟机中的hosts文件

    1、首先用xshell连接服务器,如图

    2、接着,我们打开虚拟机中的hosts文件。

    [root@localhost ~]# vi /etc/hosts

    在打开的hosts文件中,按“i”进入编辑模式,在编辑状态下,添加域名以及ip地址,如图

    三、配置HTTP服务

    1、编辑nginx配置文件

    [root@localhost ~]# vi /etc/nginx/nginx.conf

    2、在nginx配置文件配置HTTP服务,示例:

        server {
            listen 80;
            server_name ct.sdk.com;
    
            location / {
                root           /home/www/p2y9ysdk_svr/www;
                index index.php index.html index.htm;
            }
    
            location ~ .php$ {
                root           /home/www/p2y9ysdk_svr/www;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    
        }
    
        server {
            listen 80;
            server_name ct.website.com;
    
            location / {
                root           /home/www/p2y9y_website/www;
                index index.php index.html index.htm;
            }
    
            location ~ .php$ {
                root           /home/www/p2y9y_website/www;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    
        }

    四、重启web服务器nginx

    [root@localhost ~]# service nginx restart

    访问域名http://ct.sdk.com,能正常打开,如图:

  • 相关阅读:
    toLowerCase和toLocaleLowerCase的区别
    {JavaScript}栈和堆内存,作用域
    JS中的toString()和valueOf()方法
    ascii码与unicode码的区别
    js 中//<![CDATA[ 意义
    事件DOMContentLoaded和load的区别
    语义化版本
    Comet:基于 HTTP 长连接的“服务器推”技术
    [bzoj1063][Noi2008]道路设计
    [bzoj4310]跳蚤
  • 原文地址:https://www.cnblogs.com/heyongzhen/p/14958836.html
Copyright © 2011-2022 走看看