Apache 只加载"It works"而不是文件



我最近清除了硬盘驱动器,重新安装了Apache,我已经在其他网站上看到了它,但是没有任何解决方案对我有用,Apache在我做时会显示"它有效"根网站域(http://wrks.tk/)。它不显示其中的文件夹和文件。

另一个问题是,当我尝试加载我的网站文件夹(http://wrks.tk/dns)时,它给出了404个错误。

在我的httpd-vhosts.conf中:

<VirtualHost *:80>
    DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>
<VirtualHost *:80>
        DocumentRoot "/Workarea"
        ServerName wrks.tk
        ErrorLog "/Logs/Workarea/wrks-err"
        CustomLog "/Logs/Workarea/wrks-acc" common
        <Directory "/Workarea">
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

和一切都正确的位置。

EDIT 1

好吧,我在 /Library/WebServer/Documents中找到了index.html文件,其中包含"它工作!"。但这对我没有太大帮助。


EDIT 2

我将DirectoryIndex Home.php添加到我的虚拟主机中。然后在我的网站上添加了一个Home.php,并在其中放了一些东西,但我仍然得到"它有效!"。


EDIT 3

我注意到我什至无法编辑文件名,因此我将文件夹重命名为其他内容,但无效。我还尝试制作一个新文件夹。那也不起作用。

内置的apache并没有真正从包装盒中配置为开发环境。

我发现最好设置/Library/WebServer/Documents及其内部的所有内容由您的用户帐户拥有而不是由系统拥有(请记住进行更改后重新启动Apache)。

然后编辑 /etc/apache2/httpd.conf并找到用户/组,然后将其从默认值更改为也作为用户运行。这就是我的样子:

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User abhi
Group staff

然后,您可以删除index.html和所有其他垃圾。它没有用于任何东西。

您可能需要在httpd.conf中更改其他一些内容,例如使.htaccess文件能够像在典型的Linux服务器上一样充分运行。PHP也需要更改配置,例如,默认情况下它不会显示错误 - 代码中的一个错误只会给您一个空白页。

另外...安装MAMP,因为与Apple的Apache安装不同。

相关内容

最新更新