- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我使用的是 wamp 2.5 版我的 Apache 是 2.4.9PHP:5.5.12MySQL:5.6.17
我有这些配置:
在我的httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
在我的 G:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhost.conf
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "g:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "g:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "g:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:\wamp\www\mysite\public"
ServerName mysite.dev
</VirtualHost>
在我的 c:\Windows\System32\Drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
127.0.0.1 mysite.dev
# ::1 localhost
我尝试使用此 URL 访问我的项目:http://www.mysite.dev/
但是我收到一个未找到服务器错误
我尝试使用 www.mysite.dev
、 http://mysite.dev
访问它,但仍然运气不佳!
我的虚拟主机以前可以工作,但我不确定为什么现在不工作了。发生了一些奇怪的事情。
我不确定发生了什么。任何想法将不胜感激!
谢谢!
最佳答案
首先,您需要从 vhost-httpd.conf 文件中删除示例 dummy 定义。它们只是作为示例存在,只是为了让您开始使用语法,不应保留在事件的 conf/extra/httpd-vhosts.conf
中。因为它们指向不存在的文件夹。
因此从文件中删除这两个定义:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "g:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "g:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
第二个 Apache 2.4.x 支持 IPV4 (127.0.0.1) 和 IPV6 (::1),因此您的 hosts
文件应如下所示,其中包含每个站点的 IPV4 和 IPV6 版本的定义。浏览器可以任意使用其中任何一个,因此您需要两者,但如果两者实际上在您的 PC 上处于事件状态,则可能会优先使用 IPV6 网络而不是 IPV4。
127.0.0.1 localhost
::1 localhost
127.0.0.1 mysite.dev
::1 mysite.dev
现在在您系统上实际存在的 2 个虚拟主机上尝试将此作为虚拟主机定义:
<VirtualHost *:80>
DocumentRoot "g:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "G:/wamp/www">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:\wamp\www\mysite\public"
ServerName mysite.dev
ServerAlias www.mysite.dev
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
<Directory "G:/wamp/www/mysite/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<Directory>....</Directory>
<VirtualHost>....</VirtualHost>
内的部分部分告诉 Apache 允许它接受来自哪些 IP 地址的连接,因此使用 Apache 2.4 语法 Require local
限制访问,以便只有运行 WAMPServer(即 Apache)的 PC 才能连接到这些站点中的任何一个。
避免在同一定义中混合使用 Apache 2.2 语法和 Apache 2.4 语法。所以不要使用
Order Allow,Deny
Allow from all
和
Require all granted
定义相同。您使用的是 Apache 2.4,因此请使用 Apache 2.4 语法。
如果您发现您希望允许本地网络中的其他 PC 查看您的站点,即工作伙伴或 child 等,您可以将此语法添加到一个或多个虚拟主机定义中。
只允许一台其他 PC 进入您的站点
Require local
Require ip 192.168.1.100
或另外 2 台 PC
Require local
Require ip 192.168.1.100, 192.168.1.101
或者对于您本地网络上的任何人,只需使用 ip 地址的 4 个四分位数中的前 3 个。
Require ip 192.168.1
还要避免使用允许从任何地方访问的语法,即
Require all granted <--Apache 2.4 syntax
or
Order Allow,Deny <-- Apache 2.2 syntax
Allow from all
它可能会在短期内解决您的问题,但只是在等您决定要向 friend /客户/老板展示您的网站时再捕获您。如果您进入端口转发阶段,您的路由器允许世界进入您的网络,这将导致您的所有站点对世界可用。
最好更改您希望人们从 Require local
看到的用于测试/吹嘘的 ONE 站点的 ONE 虚拟主机定义。至 Require all granted
并且只允许从 Internet 访问该单个站点。
完成所有这些更改后,记得重新启动 Apache。
另外,如果您更改主机文件以使 chnages 处于事件状态,则您应该重新启动或从命令窗口的命令行运行这些命令 ising Runs as Administrator
选项。
net stop dnscache
net start dnscache
If you are using Windows 10 the above dns commands no longer work, you should do this instead.
ipconfig /flushdns
关于php - WAMP 虚拟主机不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26113258/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!