【问题标题】:Virtual host is not working in ubuntu 16.04 giving forbidden error虚拟主机在 ubuntu 16.04 中无法运行,出现禁止错误
【发布时间】:2017-08-14 05:36:48
【问题描述】:

刚才我已经在/home/invensis/test_cakephp 中安装了一个虚拟主机

 sudo mkdir -p /home/invensis/test_cakephp
sudo chown -R $USER:$USER /home/invensis/test_cakephp
sudo chmod -R 755 /home/invensis
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/test_cakephp.conf

我已经像这样更改了 test_cakephp.conf。但是虚拟主机在 test_cakephp 之外正常工作

sudo nano /etc/apache2/sites-available/test_cakephp.conf
    <VirtualHost *:80>
     ServerName test_cakephp
     DocumentRoot /home/invensis/test_cakephp/
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>

在这之后我已经使用了

sudo service apache2 reload

然后我使用编辑主机

sudo nano /etc/hosts 

但是当我运行 localhost test_cakephp 时,我收到了诸如您无权访问此服务器上的 / 之类的错误。 Apache/2.4.18 (Ubuntu) 服务器在 test_cakephp 端口 80。 您无权访问此服务器上的 /favicon.ico。 Apache/2.4.18 (Ubuntu) 服务器在 test_cakephp 端口 80。

我也试过这个。但这对我也不起作用。 选项索引 FollowSymLinks AllowOverride 无 要求全部授予

【问题讨论】:

    标签: apache ubuntu


    【解决方案1】:

    编辑DocumentRoot 应指定不带斜杠:

    DocumentRoot /home/invensis/test_cakephp

    您必须启用 VirtualHost,然后重新加载:

    sudo a2ensite test_cakephp
    sudo service apache2 reload
    

    如果你想再次禁用它:

    sudo a2dissite test_cakephp
    sudo service apache2 reload
    

    【讨论】:

    • 我也做过,但我忘了提
    猜你喜欢
    • 2015-05-24
    • 2012-11-04
    • 2017-06-02
    • 1970-01-01
    • 2012-02-11
    • 2016-06-11
    • 2013-04-28
    • 2013-07-14
    • 2016-08-14
    相关资源
    最近更新 更多