3

您好,我一直在寻找互联网文章论坛来解决我的问题,但到目前为止无济于事。我正在尝试在 localhost 上为我的 FuelPHP 开发设置一个 Apache 虚拟主机,但我一直受到错误 403 消息的抨击。这是我目前的设置。

#/etc/apache2/sites-enabled/000-default
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot "/home/supercomputer/Desktop/PHP/fuelProject/public"
    ServerName   localhost.home
    <Directory "/home/supercomputer/Desktop/PHP/fuelProject/public" >
        Options Indexes FollowSymLinks MultiViews Includes ExecCGI
        AllowOverride All
        Order Allow,Deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

我已将我的 Docroot 指向我的fuelProject 中的公用文件夹。另外,为了确保 Apache 可以访问服务器文件,我将所有文件的权限设置为递归地读取、写入和执行,以确保 100% 安全。关于还有什么可能出错的任何线索?

PS:我正在运行ubuntu raring(13.04)

PSS:我正在尝试访问 localhost.home 和 localhost.home/index.php。重新启动服务器时,我还会收到以下警告

* Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri May 03 15:46:58 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Fri May 03 15:46:59 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
4

3 回答 3

4

这是为fuelphp应用程序或任何其他php应用程序添加Vhost的正确方法

<VirtualHost *:80>
    ServerName localhost.home
    DocumentRoot /home/supercomputer/Desktop/PHP/fuelProject/public
    ServerAdmin webmaster@localhost
    <Directory /home/supercomputer/Desktop/PHP/fuelProject/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

而且下面的行也不是必需的我不知道你为什么添加

NameVirtualHost *:80

完成上述所有操作后,将主机条目添加到您的机器以执行此操作

sudo vi /etc/hosts

添加虚拟主机的条目

127.0.0.1  localhost.home

在做了所有这些事情之后

通过运行重新启动 Apache

sudo /etc/init.d/apache2 restart 

只需在您的浏览器中加载http://localhost.home,您应该能够看到您的站点启动并运行。

如果您仍然收到禁止错误。您需要授予整个应用程序文件夹的权限

按照运行这些命令来执行此操作

sudo chown -R www-data:www-data /home/supercomputer/Desktop/PHP

sudo chmod -R 775 /home/supercomputer/Desktop/PHP

最后将自己添加到 www-data 组

sudo adduser yourUserName www-data
于 2013-05-05T16:11:49.757 回答
0

在 Ubuntu 14.04 上测试:我做了上面的一切,但我没有工作。我错过了允许访问apache2.conf中的目录。如果您不使用 /var/www 或 /usr/share/ 之类的标准目录,则需要这样做。

<Directory /usr/local/vufind>
    Options Indexes FollowSymLinks
    AllowOverride All 
    Require all granted
</Directory>

这在 4 默认 PHP 站点上有所提及。值得一读!

于 2015-02-02T09:36:18.177 回答
0

我发布的配置正在运行。问题出在权限上。我只将包含燃料项目的文件夹设置为权限 777,但出于某种原因,apache 想要访问几乎所有包含它的文件夹。我知道很奇怪,但是将所有权限设置为 777,它起作用了。阅读该死的 apache 日志确实有帮助。如果您遇到类似的问题,我建议您找到 apache 日志并实际阅读

于 2013-05-28T22:37:31.850 回答