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,能正常打开,如图:

  • 相关阅读:
    XML注释
    Mysql 查询不重复数据
    java 支持跨域
    蓝桥杯历届试题-打印十字图--Java
    以流的方式读取url中的参数
    写log日志,并读取log日志
    Java Memcached的使用
    PageInfo实现分页
    java swing 窗口在屏幕中默认显示的位置 居中位置显示
    简易计算器布局 BorderLayout JPanel GridLayout 混合
  • 原文地址:https://www.cnblogs.com/heyongzhen/p/14958836.html
Copyright © 2011-2022 走看看