Mac下配置虚拟主机

Mac下配置虚拟主机

mac下配置虚拟主机
查看Nginx配置文件路径,在不同的安装环境配置下配置文件的路径不相同
➜  nginx brew info nginx
nginx: stable 1.12.1 (bottled), devel 1.13.4, HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.12.1 (23 files, 1MB) *
  Poured from bottle on 2017-08-29 at 10:52:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/nginx.rb
==> Dependencies
Required: pcre ✔, openssl@1.1 ✔
Optional: passenger ✘
==> Options
--with-debug
	Compile with support for debug log
--with-gunzip
	Compile with support for gunzip module
--with-passenger
	Compile with support for Phusion Passenger module
--with-webdav
	Compile with support for WebDAV module
--devel
	Install development version 1.13.4
--HEAD
	Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that  //Nginx配置文件路径
nginx can run without sudo.   

nginx will load all files in /usr/local/etc/nginx/servers/.    

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
在上面的命令执行之后我们可以找到Nginx的配置文件路径地址:
/usr/local/etc/nginx/nginx.conf
使用vim 编辑器打开
➜  nginx sudo vim nginx.conf
server {
 36         listen       80; //监听的端口
 37         server_name  cangck.com; //域名访问
 38
 39         #charset koi8-r;
 40
 41         #access_log  logs/host.access.log  main;
 42
 43         location / {
 44             root  /usr/local/var/www/Thinkphp/public; //网站的工程目录,也就是index.php的目录路径名称
 45             index  index.php index.html index.htm;  //添加index.php 主要是让服务器能够去找到index.php文件
 46         }
 47
 48         #error_page  404              /404.html;
 49
 50         # redirect server error pages to the static page /50x.html
 51         #
 52         error_page   500 502 503 504  /50x.html;
 53         location = /50x.html {
 54             root   html;
 55         }
 56
 57         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 58         #
 59         #location ~ \.php$ {
 60         #    proxy_pass   http://127.0.0.1;
 61         #}
 62
 63         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 64         #
 65         location ~ \.php$ {//对php的设置参数
 66             root           html;
 67             fastcgi_pass   127.0.0.1:9000;
 68             fastcgi_index  index.php;
 69             fastcgi_param  SCRIPT_FILENAME /usr/local/var/www/Thinkphp/public$fastcgi_script_name;//配置脚本文件的路径,下面一行是
原始的配置信息,这需要把/scripts修改为index.php所在路径的全路径即可(/usr/local/var/www/Thinkphp/public)
 70 #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 71             include        fastcgi_params;
 72         }
添加域名相关的内容到/etc/hosts中即可:
➜  ~ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
127.0.0.1 cangck.com
127.0.0.1 center.com
127.0.0.1 onethink.com
127.0.0.1 services.com
127.0.0.1 localswagger.com
127.0.0.1 swagger-editor.com
127.0.0.1 wxpay.com
➜  ~





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Docker中,macvlan网络是一种特殊的网络类型,它允许容器直接通过物理网络接口访问宿主机上的网络,甚至可以在多个主机之间配置macvlan网络,从而实现容器之间的通信。 macvlan网络的工作原理是基于Linux内核的一个特性,即虚拟网络接口。当创建一个macvlan网络时,Docker会创建一个虚拟网络接口,并将其绑定到宿主机上的物理网络接口上。然后,容器可以使用这个虚拟网络接口访问宿主机上的网络,甚至可以获得与宿主机相同的IP地址和MAC地址。 在多个主机之间配置macvlan网络时,需要在每个主机上创建macvlan网络并绑定到相同的物理网络接口上。这样,容器就可以在不同的主机之间使用相同的macvlan网络进行通信。 需要注意的是,在使用macvlan网络时,容器将获得与宿主机相同的IP地址和MAC地址,因此需要确保在所有主机上使用不同的IP地址和MAC地址来避免冲突。另外,macvlan网络可能会导致网络性能下降,因此需要进行性能测试和优化。 下面是一个跨主机配置macvlan网络的示例: 1. 在主机A上创建macvlan网络: ``` $ docker network create -d macvlan \ --subnet=192.168.1.0/24 \ --gateway=192.168.1.1 \ -o parent=eth0 \ mynet ``` 其中,eth0是主机A上的物理网络接口名称。 2. 在主机B上创建相同的macvlan网络: ``` $ docker network create -d macvlan \ --subnet=192.168.1.0/24 \ --gateway=192.168.1.1 \ -o parent=eth0 \ mynet ``` 3. 在主机A上启动一个容器,并加入mynet网络: ``` $ docker run -it --network=mynet alpine sh ``` 4. 在主机B上启动另一个容器,并加入mynet网络: ``` $ docker run -it --network=mynet alpine sh ``` 现在,这两个容器可以通过mynet网络直接进行通信。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值