Vagrant - CentOS 网络设置

3

我已经配置好了一个Vagrant虚拟机,具体配置如下 --

Vagrant.configure("2") do |config|
  config.vm.box = "intprog/centos7-ez6"
    config.ssh.insert_key = false
    config.vm.network "public_network", ip: "192.168.33.243"
    config.vm.provision "file", source: "/server/bin/nginx/conf/domains-enabled/cemcloudMigration.conf", destination: "~/cemcloud.conf"
    config.vm.provision "shell", path: "webroot/bootstrap/script.sh"
end

这是我的脚本的样子 -- sudo su
#update the centos version
#yum update -y

yum -y erase httpd httpd-tools apr apr-util
#getting nginx from the right address
yum install -y http://http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm
yum install -y nginx

#installing composer
curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar
mv composer.phar /usr/bin/composer

cd /srv/www/cemcloud2
composer install

#removal of old mariadb5.5 and installation of the new one
yum -y remove mariadb-server mariadb mariadb-libs
yum clean all
yum -y install MariaDB-server MariaDB-client

#clear unnecessary software
yum -y remove varnish

## restart the service
service mysql restart
service php-fpm restart
service nginx restart

/var/log/nginx/access.log正在生成以下内容--

10.0.2.2 - - [17/Oct/2016:11:42:10 +0000] "GET / HTTP/1.1" 301 185 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0" "-"

Nginx的行为真奇怪,因为有时它会生成日志,而有时又不会。当我使用Firefox开发者工具时,它会生成日志,但当我使用Google Chrome时就不会。

每次我在浏览器中输入网址时,都会显示:

连接已超时。

总之,我想要连接到这台计算机,我做错了什么?

2个回答

3
请在虚拟机上检查您的网络连接,方法如下:
nmap -sT -O localhost

请检查您在nginx配置中使用的端口是否已开放。 如果没有开放,请在防火墙中打开它们并再次检查。


1
这是 "intprog/centos7-ez6" 计算机内部的防火墙问题,它没有监听 https 端口。我按照以下步骤进行操作:
  1. firewall-cmd --add-service=https
  2. firewall-cmd --add-service=https --permanent
  3. firewall-cmd --reload
一切正常工作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接