方法一:
1.修改apache默认网站配置文件
vi /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /filedata/html
#DocumentRoot /var/www/htmlErrorLog ${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>
然后检查自己项目的配置文件,把路径指定到此根目录下的项目文件夹,就可以了。
教程 在我的另一篇博客 服务器创建子域名指向特定目录