在apache2服务器上部署Web应用程序

时间:2014-12-28 14:47:10

标签: php apache ubuntu

我在Ubuntu上安装/设置了PHP5和Apache2服务器,并尝试在其上部署虚拟项目。

enter image description here

服务器已启动并正在运行。但是网址http://localhost/DemoWebApp为我提供了

Apache/2.4.7 (Ubuntu) Server at localhost Port 80

enter image description here

我做错了什么或如何正确设置?

编辑:

项目结构:

enter image description here

4 个答案:

答案 0 :(得分:2)

将DemoWebApp移动到html文件夹中,它应该可以正常工作

答案 1 :(得分:1)

DocumentRoot中的/etc/httpd/httpd.conf设置为/var/www或将DemoApp文件夹移至/var/www/html

答案 2 :(得分:0)

我没有ubuntu方便 - httpd -S 看看你是否列出了虚拟主机。

我假设localhost(没有目录) - 应该做什么

看起来你的目录配置不正确

答案 3 :(得分:-1)

看起来您尚未正确配置DemoApp。检查DemoApp文件夹中的文件。还要确保您的应用程序在端口80上运行。因为如果应用程序在某个其他端口(而不是默认端口80)上运行,则可能会发生这种情况。

设置好所有内容后,重新启动apache。

sudo service apache2 restart

编辑(在DemoApp文件夹中看到您的文件后) 另一个问题可能是index.php没有被服务器加载/识别。签入httpd.conf,(有时只将index.html识别为默认索引文件。)。如果未将其设置为默认索引文件,请在httpd.conf中添加以下行

<Directory /DemoApp>
DirectoryIndex index.php
</Directory>

另一种方法是创建.htaccess文件并添加以下行:

DirectoryIndex index.html index.php