apache虚拟主机子域只能由localhost访问

时间:2015-07-08 20:35:39

标签: linux apache centos xampp virtualhost

我尝试让我的pic.localhost虚拟主机可以访问公共网络(所有互联网) 现在问题是它只能在地址pic.localhost中的同一台机器上工作,但即使是lan网络也无法访问它,只能由运行它的机器访问。我该怎么办?

我添加并编辑了这些文件以使我的图片子域名网站: 1 - 我在httpd-vhosts文件中包含了httpd.conf文件。 2 - 我添加到httpd-vhosts文件这一行:

<VirtualHost *:80>
    ServerAdmin admin@domain
    DocumentRoot "/opt/lampp/htdocs/"
    ServerName pic.localhost
#    ServerAlias www.pic.localhost
    ErrorLog "logs/picture-error_log"
    CustomLog "logs/picture-access_log" common
</VirtualHost>

3 - 我将此行添加到/etc/hosts

127.0.0.1                pic.localhost

4 - 我重启了xampp服务器

我在xampp 5.6.8计算机上运行Centos 7

1 个答案:

答案 0 :(得分:0)

Centos 7 防火墙,默认情况下阻止某些端口(包括端口80)。 在命令行中,使用sudo权限尝试..

service firewalld stop

然后在终端中看到 CENTOS LAN IP (ifconfig)并尝试访问该IP(ex 192.168.1.100)。  如果您能够访问Web服务器。然后尝试从另一台机器和浏览器中选择http://centos-lan-ip,其中centos-lan-ip是你的centos机器IP。

希望这有效

相关问题