ubuntu给Apache指定网站根目录

8 篇文章 0 订阅
4 篇文章 0 订阅

方法一:

1.修改apache默认网站配置文件

vi /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /filedata/html
    #DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
 

访问报错

You don't have permission to access / on this server

2.修改Apache配置文件,做如下改动

<Directory />
    Options FollowSymLinks
    AllowOverride None
    #Require all denied
    allow from all

</Directory>
 

方法二:

情况: 原来的项目代码什么的都在系统盘放着,后来不够了,就买了一个数据盘,只是有的项目暂时还不能迁移,就先把部分的项目迁移到挂载盘里,这时候,配置好文件,出现了报错。

Forbidden

You don't have permission to access / this server.

很简单 

vi /etc/apache2/apache2.conf

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

找到上面的部分,复制,在下面粘贴,修改目录为自己新加的根目录。如 

新的根目录为 /myfile

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /myfile>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

然后检查自己项目的配置文件,把路径指定到此根目录下的项目文件夹,就可以了。

教程 在我的另一篇博客 服务器创建子域名指向特定目录

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值