为什么我的虚拟主机XAMPP无法显示php文件?
我正在尝试设置一个虚拟主机,以便我可以从 Eclipse 将 .php 文件作为网页运行。
我按照此讨论中的说明进行操作:
Make XAMPP/Apache 在外部提供服务文件htdocs
向下滚动到虚拟主机,指令基本上是
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/Oky/Documents/eclipse/firstEclipseProject/"
ServerName firstEclipseProject.localhost
ErrorLog "/Users/Oky/Documents/eclipse/firstEclipseProject/logs/error_log"
<Directory /Users/Oky/Documents/eclipse/firstEclipseProject/>
Order allow,deny
Allow from all
</Directory>
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
The document is at /Application/XAMPP/etc/extra/httpd-vhosts.conf
然后我在 更改主机文件/private/etc/hosts
在底部,我添加了
127.0.0.1 firstEclipseProject.localhost #firstEclipseProject
所以,我认为我到目前为止正在做这件事,因为当我启动浏览器并指向 firsteclipseproject.localhost
时,它会将我重定向到
firsteclipseproject.localhost/XAMPP/
XAMPP 主网页。它不会返回未找到的对象/页面,这意味着重定向在某种程度上起作用。
所以,在 /Users/Oky/Documents/eclipse/firstEclipseProject/ 我创建了一个名为 HelloWorld.php
的 php 文件,但是当我指向 firsteclipseproject.localhost/HelloWorld.php
时,它说找不到对象!我还尝试了firsteclipseproject.localhost/XAMPP/HelloWorld.php,但失败了。
任何帮助表示赞赏!谢谢!!!
I am trying to set up a virtual host so that I can run my .php file from Eclipse as a web page.
I follow the instructions from this discussion:
Make XAMPP/Apache serve file outside of htdocs
Scroll down to virtual hosts and the instruction is basically
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/Oky/Documents/eclipse/firstEclipseProject/"
ServerName firstEclipseProject.localhost
ErrorLog "/Users/Oky/Documents/eclipse/firstEclipseProject/logs/error_log"
<Directory /Users/Oky/Documents/eclipse/firstEclipseProject/>
Order allow,deny
Allow from all
</Directory>
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
The document is at /Application/XAMPP/etc/extra/httpd-vhosts.conf
Then I change the hosts file at /private/etc/hosts
and at the bottom, I added
127.0.0.1 firstEclipseProject.localhost #firstEclipseProject
So, I think I am doing it right up to this point because when I fire my browser and point to firsteclipseproject.localhost
, it redirects me to
firsteclipseproject.localhost/XAMPP/
which is the main XAMPP web page. It does not return an object/page not found which means the redirecting is somewhat working.
So, in /Users/Oky/Documents/eclipse/firstEclipseProject/
I created a php file called HelloWorld.php
but when I point to firsteclipseproject.localhost/HelloWorld.php
, it says object not found! I also tried firsteclipseproject.localhost/XAMPP/HelloWorld.php
and it fails.
Any help is appreciated! Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您保留根目录不变,而是为您的 eclipse 目录设置一个别名。
I would suggest you leave the root directory the way it is and instead setup an Alias to your eclipse directory.
更改配置后是否重新启动 apache?
Did you restart apache after making config changes?