首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Range6项目和wamp服务器无法从同一网络上的其他计算机访问该项目

Range6项目和wamp服务器无法从同一网络上的其他计算机访问该项目
EN

Stack Overflow用户
提问于 2018-10-18 09:07:20
回答 2查看 453关注 0票数 0

我正在使用wampserver作为本地服务器作为我的角应用程序。

我使用ng build --prod --aot命令构建了我的应用程序。然后,我将dist文件夹放入一个名为angular.local的虚拟主机中,在httpd-vhosts.conf配置文件中有以下脚本:

代码语言:javascript
运行
复制
<VirtualHost *:80>
    ServerName angular
    DocumentRoot "c:/wamp64/www/angular"
    <Directory  "c:/wamp64/www/angular/">
        #Options +Indexes +Includes +FollowSymLinks +MultiViews
        #AllowOverride All
        #Require local
        Allow from 127.0.0.1
        Allow from 192.168.0.140
        Require all granted
    </Directory>
</VirtualHost>

其中192.168.0.140是用户笔记本电脑的网络IP地址,我们将从其中访问应用程序。

在servers system32主机文件中,我添加了以下行:

代码语言:javascript
运行
复制
192.168.0.109 angular.local
::1 angular.local

其中192.168.0.109是服务器的IP地址。

当用户尝试使用链接访问应用程序时:

http://192.168.0.109/angular/

我们可以在google选项卡标题上看到应用程序的标题,但是控制台上有3个错误:

在此运行时,找不到样式和主java脚本文件。

我在服务器角文件夹上检查了它们,它们确实存在。

我所做的和提到的在这个链接中一样。

我在项目文件夹中有.htaccess。

我可以使用http://192.168.0.109/访问本地主页。

我试过使用以下链接,但没有成功:

http://angular.local/

有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-18 09:23:08

通过使用APache 2.2语法和Apache2.4语法,您混淆了APache。所以,坚持使用Apache2.4语法。

另外,你ServerName应该是ServerName angular.local

代码语言:javascript
运行
复制
<VirtualHost *:80>
    ServerName angular.local
    DocumentRoot "c:/wamp64/www/angular"
    <Directory  "c:/wamp64/www/angular/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
        Require ip 192.168.0.140
    </Directory>
</VirtualHost>

和另一个用于dev.local的VH,因此假设它位于一个名为dev的文件夹中,在www下。

代码语言:javascript
运行
复制
<VirtualHost *:80>
    ServerName dev.local
    DocumentRoot "c:/wamp64/www/dev"
    <Directory  "c:/wamp64/www/dev/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
        Require ip 192.168.0.140
    </Directory>
</VirtualHost>

如果您想要允许从本地网络中的任何ip,那么我们而不是上面的

代码语言:javascript
运行
复制
Require ip 192.168.0

假设WAMPServer运行在ip 192.168.0.10上,您还必须将域名添加到其他pc上的主机文件中。

代码语言:javascript
运行
复制
192.168.0.10 angular.local
192.168.0.10 dev.local
票数 1
EN

Stack Overflow用户

发布于 2018-10-18 09:29:56

使用以下代码:

代码语言:javascript
运行
复制
<VirtualHost *:80>

 ServerName servername.com
 DocumentRoot path/to/dist

 <Directory "path/to/dist">
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
 #   Require local
 </Directory>

</VirtualHost>

我有相同的角度应用程序,使用ng build构建并将dist文件夹添加到apache2和更高版本是我的vhosts.conf文件。完美地为我工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52870626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档